I have a project that included 3 windows services, the services were worked very well, then for business needs, we need to move from windows server 2008 to windows server 2019.
The issue which I faced is:
When I install the services, It didn't start and returned the error in the Event Viewer:
Service cannot be started. System.Security.SecurityException: The source was not found, but some or all event logs could not be searched. Inaccessible logs: Security, State.
I searched for this issue and I found a lot of answers ( like this) but it won't help me.
I installed the services in Command Line as administrator using InstallUtil.exe.
Then opened the Registry Editor and give the user NETWORK SERVICE a full control in the path as below:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\Application
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog\Security
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\eventlog
Then I check the subkey of the services in the path:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\EventLog\Application
Also, it exists.
My code related to EventLog :
public class EventViewer
{
public static void WriteEvent(string ServiceName, string msg, EventLogEntryType _EventLogEntryType)
{
EventLog eventLog = new EventLog();
eventLog.Source = ServiceName;
eventLog.Log = "Application";
((System.ComponentModel.ISupportInitialize)(eventLog)).BeginInit();
if (!EventLog.SourceExists(eventLog.Source))
{
EventLog.CreateEventSource(eventLog.Source, eventLog.Log);
}
((System.ComponentModel.ISupportInitialize)(eventLog)).EndInit();
eventLog.WriteEntry(msg, _EventLogEntryType);
}
}
The Event Viewer give me the line of the exception and it refers to:
((System.ComponentModel.ISupportInitialize)(eventLog)).BeginInit();
I tried to debug the service on my machine using Visual Studio 2019, but also give me the same error, and the service wouldn't start to debug using "Attach to Process".
I think the issue is while scanning the registry to check if the event source exist.
https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.eventlog.createeventsource?view=dotnet-plat-ext-6.0
As per Microsoft the account requires administrative privilege to do this task.
I have also seen there is a new registry hive under 'EventLog' called 'state' in windows 2019 which has less access compared to other hives.
Debug with process monitor and see if you are getting access denied in that hive.
Related
I have a .NET Core 3.0 app where am trying to connect to a Azure SQL database using EF Core and Active directory integrated authentication.
I have verified that I have access to this database from my machine as I can connect to it just fine using SQL server management studio and 'Azure Active Directory-Integrated' authentication.
However, when I try to read data in my app (using EF Core), I always get a System.Argument exception with the following statement:
Invalid value for key 'authentication'
Exception details point to the Db connection string.
So, here is my connection string from my dev appsettings.json file:
"ConnectionStrings": {
"MCDB": "Server=tcp:dev-media-center-sql.database.windows.net,1433;Initial
Catalog=MediaCenter;Persist Security Info=False;User
ID={my User ID};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication=Active Directory Integrated;" },
I have tried hard coding the connection string directly in my code, thinking that there might be a problem with my JSON but I still get the same exception.
Is "Active Directory Integrated" not a valid value for the 'Authentication' keyword? If not, what is it then? I have already tried "ActiveDirectoryIntegrated" (with no spaces) and /"Active Directory Integrated"/ (escaping double quotes) but to no avail.
Thanks
Fike
Here's what did it for me:
If you're using EF Core with package Microsoft.EntityFrameworkCore.SqlServer...
Then be aware:
The Microsoft.Data.SqlClient package ships more frequently than the EF
Core provider. If you would like to take advantage of new features and
bug fixes, you can add a direct package reference to the latest
version of Microsoft.Data.SqlClient.
source: https://learn.microsoft.com/en-us/ef/core/providers/sql-server/?tabs=dotnet-core-cli
That being said ๐, the fix was EASY. Just add the package to your project ๐
upgraded to latest version of Microsoft.Data.SqlClient and the issue is resolved.
Hope this will help someone
This is essentially the same problem discussed in relation to a newer .NET Core version, which was answered as currently unsupported in that version, however I have added a comment where I note that it now works - see EF Core 3.1 using Authentication=Active Directory Integrated
If your only option for connecting to the Azure SQL Database is through Active Directory authentication, and your ADO.NET SqlConnection object is having problems trying to recognize the "Active Directory Integrated" value as the Authentication, you can still use the "Active Directory Password" value if you know the credentials of the user you're using to try to connect to the database. The connection string will be something like this:
"Server=tcp:yourservername.database.windows.net,1433;Initial Catalog=yourdatabasename;Persist Security Info=False;User ID={your_username};Password={your_password};MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication="Active Directory Password";"
That worked for me.
You can use "Authentication=Active Directory Managed Identity" and be sure to set the User ID to the Object(principal)ID of the identity.
Example:
Data Source=dev-westeurope-001.database.windows.net;Initial Catalog=dev-westeurope-001;Authentication=Active Directory Managed Identity;User ID=[PrincipalId];TrustServerCertificate=True;
I'm developing a web application (ASP.Net Core) in a servicefabric cluster, but every time I get an error in a razor view (for example a variable not set) I get a 404 error and not the well known error page which tells me what is wrong.
I have no clue as to why it does that or how I should solve it and can't find anything online. Can anyone point me in the right direction?
The project used to run outside the cluster and debugging worked there but since it's in the cluster it doesn't.
Visual Studio is currently not able to set the ASPNETCORE_ENVIRONMENT for Service Fabric Services.
You can workaround this problem by changing this code in the default Configuration method in your Startup.cs file to this:
//if (env.IsDevelopment())
if (env.ContentRootPath.Contains("SfDevCluster"))
{
app.UseDeveloperExceptionPage();
app.UseBrowserLink();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
That should be a fairly safe assumption that you are running the application in a OneBox Service Fabric cluster.
I've been trying to allow a program I am writing to access Google Drive Applications. I have gotten the client secrets information successfully, and have copy and pasted the example code and tried using it to successfully authenticate my program and use the google drive API.
However, when it gets to the line
Credential credential = new AuthorizationCodeInstalledApp(flow, new LocalServerReceiver()).authorize("user");
I get this error. This error has been posted about before, and I've tried essentially every solution. I've elevated both my program and all the java.exe files to administrator and tried running the program and I still got this error.
The full error is:
Oct 03, 2015 11:48:39 AM com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for everybody: D:\directory
Oct 03, 2015 11:48:39 AM com.google.api.client.util.store.FileDataStoreFactory setPermissionsToOwnerOnly
WARNING: unable to change permissions for owner: D:\directory
I've also tried overriding the setPermissionToOwnerOnly when I instantiated the FileDataStoreFactory but that failed as well.
I have tried the following solutions:
http://stackoverflow.com/questions/30634827/warning-unable-to-change-permissions-for-everybody
http://stackoverflow.com/questions/24382069/error-while-executing-google-prediction-api-command-line-sample
https://groups.google.com/forum/#!topic/google-analytics-data-export-api/-7BH7Z40gkw (where the client secret data was hard coded into the program, this is bad, I know, but it didn't work anyway)
I don't know what to do at this point. I am running my program off a flash drive, and I tried running it off my computer as well, but it still failed. I am using NetBeans 8.0.2.
The error comes up as a warning, so maybe there is some way to just ignore the warning and proceed? That could be a solution, but I've researched and I'm not sure if that's a possibility. I am running windows 10 if that matters.
I just ran the Drive REST API example Java Quickstart tutorial through Eclipse and is working fine. It does requires a bit of setup time if you have not install Gradle (also Eclipse Marketplace has a plugin for Gradle).
To your point, I did get the same warning messages. However, it happened for me during the load client secret in the authorize() method.
public static Credential authorize() throws IOException {
// Load client secrets.
InputStream in =
DriveQuickstart.class.getResourceAsStream("/client_secret.json");
GoogleClientSecrets clientSecrets =
GoogleClientSecrets.load(JSON_FACTORY, new InputStreamReader(in));
I suspect this is where your issue is happening. Since, I am not able to see that part from your code snippet, have a look at where your client_secret.json file is located.
Hope this helps. Good luck!
When I launch a Windows 8 app from Worklight 6.0 using Run->Visual Studio Project, the app is launched inside VS using 169.254 (linnl local block) Ip address regardless the correct IP I have used using the Build for Remote Server.
Looking the generated html file inside Eclipse it looks correct, however when I launch it it gets a wrong ip address for some reason inside Visual Studio.
Here is the code snnipet with the wrong ip address
<script>
// Define WL namespace.
var WL = WL ? WL : {};
/**
* WLClient configuration variables.
* Values are injected by the deployer that packs the gadget.
*/
WL.StaticAppProps = {
"APP_DISPLAY_NAME": "My App",
"APP_ID": "cnu",
"APP_SERVICES_URL": "http:\/\/169.254.80.80:9080\/cnu\/apps\/services\/",
"APP_VERSION": "1.0",
"ENVIRONMENT": "windowsphone8",
"LOGIN_DISPLAY_TYPE": "embedded",
"WORKLIGHT_PLATFORM_VERSION": "6.0.0",
"WORKLIGHT_ROOT_URL": "http:\/\/169.254.80.80:9080\/myapp\/apps\/services\/api\/cnu\/windowsphone8\/"
};</script>
Am I doing something wrong ?
If it is overwriting the IP that you specified on build for Remote server when you launch into Visual Studio, then that's a problem. It ought to work the way you are trying.
One possible workaround is to not launch Visual Studio out of eclipse, but launch it from the Windows tiles page, and explicitly load the project in the Win8 native folder in your app.
Then whenever you switch back to Eclipse and do a build, upon returning to VS, it should notice that something changed and prompt you to reload the project.
I do this anyway, because the cycle time to build and test is shorter if you leave both eclipse and VS running.
My Windows Store app keeps getting rejected from certification testing and I managed to reproduce a consequent crash when running appverif's LuaPriv-check. I get this output though:
AVRF: failed to create verifier log file \??\C:\Users\xx\AppVerifierLogs\yy.exe.0.dat (status C0000022)
Process Monitor tells me yy.exe got ACCESS DENIED on a CreateFile operation in this folder. I have set full access to all users (the user reported in the log was the same as the owner of the folder). I am running Visual Studio and Application Verifier as Administrator, but this does not seem to apply. What is the correct way of giving user xx full access to this folder on win8? I have attempted to use different log folders for appverify but with no success. Anyone else able to use this tool with Store-apps?
This post describes similar issues. Attempting to run AppVerif โsppath C:\MyLogsLocation as in the suggested workaround gives AVRF: Error: Incorrect image name: <
So does running appverif -enable handles locks -for myapp.exe -sppath c:\MyLogsLocation
It might be a bug in app verifier.
Have a look at these links:
http://social.technet.microsoft.com/Forums/en-US/5ed560c0-76af-401d-8150-8cd1e69d0b8a/why-app-verifier-can-not-create-log-file?forum=windowssdk
http://blogs.msdn.com/b/dougste/archive/2010/01/11/generating-application-verifier-logs-for-web-applications.aspx
0xc000022 is STATUS_ACCESS_DENIED. The process doesn't actually have write permissions, even if it looks like it should. This MSDN blog explains there is a bug in App Verifier so even if you specify -sppath the value won't be honoured unless you first delete the %WINDIR%\system32\config\AppVerifierLogs\ folder.