Just installed our application on a client's server, and we are seeing an error that we have never seen before. This program runs on hundreds of computers and servers around the world, and apparently this one is different. Our client is fairly security conscious, so I'm guessing we need to have them unlock something, but no idea where to start. Google search of the issue only gives me a bunch of PowerShell references.
When calling System.Reflection.Assembly.LoadFile() to load in a DLL, we receive an "Operation is not supported" error.
This is a .NET 4.0 C# application.
Thanks
Went to each non-working DLL, properties, UNBLOCK. Restarted our service, and everything started working.
Related
I'm migrating a working ASP.NET web application from WS2008R2 to WS2016, but the same happens on WS2012R2. It fails when executing:
new System.Printing.PrintServer(#"\\printserver");
It throws:
System.Exception: An exception occurred while creating the PrintServer
object. Win32 error: The printer name is invalid.
printserver is not an alias but a hostname. It loads correctly on Windows Explorer. The same line works fine on a regular Console Application when compiling under the same .NET 4.5.2, and also in PowerShell when loading the System.Printing.dll. The GAC shows the right assemblies, and I've also added them manually just in case.
I've set the same application pool configuration settings from the working WS2008 (disabled 32-bit applications and Classic mode), but I've tried different combinations in any case. The application pool runs under the same domain service account on both old and new.
As some user also suggested, I've installed the Print and Document services role, even though the old server doesn't have it, but to no avail.
I'm out of ideas, any kind of help would be greatly appreciated. Thanks!
Not really a solution... But I "fixed" this by changing the path of the website in IIS manager back and forth a couple of times. Yes, after a year of trying all I could think of on several servers.
Anyway, not sure what exactly unblocked the situation, but it works for me.
I have an ASP.NET Webforms Application on Azure but i always get the following Error on some sites:
502 - Web server received an invalid response while acting as a gateway or proxy server.
I already read a lot of topics regarding the 502 error on Azure but i still don't understand what the problem in my particular situation is.
The error occurs just on some site of the application. I can always reproduce the following pattern:
Open SITENAME.azurewebsites.net -> Error occurs
Open SITENAME.azurewebsites.net/Site1.aspx -> Error not occuring
Open SITENAME.azurewebsites.net/Site2.aspx -> Error not occuring
Refresh SITENAME.azurewebsites.net/Site2.aspx -> Error occurs and won't go away until i call Site1.aspx again
The only thing i found in the log is, that the application loads System.Windows.Forms.dll and there is an AccessViolationException. I have no idea why this dll is loaded at all because there is no Reference in any Project in Visual Studio to it but thats another story :).
But what i don't understand is that the error 502 does not always occur on Site 502.
Maybe someone can give me a hint what might be the problem or how i could find it...
Thanks for your help!
EDIT:
What i forgot to mention: In some threads regarding this error i read, that it occurs after 3 minutes or something like that. In my case it is nearly alway about 25 seconds until the errormessage shows up.
That points to an application issue. The reason you are etting 502 is because the worker process is crashing and the front end is left with a request with no response and returning a 502 to say exactly that. Look for eventlog.xml under the LogFiles folder for your website. Alternatively you can try remote debugging from VS to your website.
System.Windows.Forms.dll contains a lot of UI code that will most probably not work Azure websites sandbox. The reason it's loaded is probably because you are using something from the assembly or using something that uses something from that assembly. It doesn't have to be listed in Visual Studio to be loaded since it's a part of the standard .NET Framework.
I would suggest looking into remote debugging and figuring out at what point this is getting loaded and why.
In my case, I got 502 errors because the site was restarted by the azure auto-heal system. It turns out I made tests with that auto-heal system a few days ago, but since in the end I disabled it, I didn't think it could cause my 502 errors.
This is where I discovered that the azure interface to change auto-heal settings (mywebsite.scm.azurewebsites.net/Support -> mitigate) only affects the production slot. But when you swap your deployment slots, the settings get swapped. There is apparently no way to directly change the staging slot settings, you have to swap, change settings, and swap again.
So, I ended up having my staging slot with auto-heal enabled, and my production slot with auto-heal disabled (and of course at that time I thought it was disabled on both slots). Then I was "randomly" hitting 502 errors either on staging or production depending on how many times I swapped them. What's weird is that though the application seems to restart (or at least fails to respond to a few requests), I don't get the corresponding events in my log file, like if it wasn't running Application_Start after an app pool recycle triggered by the auto-heal system.
Took me a whole day to find out what was happening, I hope this answer can help someone in the same situation.
I got the error for a while after fiddling with connection strings, went away and came back in an hour, and the issue had disappeared and the site worked normally again. A highly technical answer for you.
Whenever I debug my application (ASP.NET Web Application converted to Web Role), I am able to get to the login page. I go ahead and sign in, debug through that and it seems to work fine, but as soon as it takes me to the landing page after login, DevFC.exe stops working with the error:
An unhandled exception ('System.Net.Sockets.SocketException') occurred in DevFC.exe [8072].
Now, I've searched for the issue and have seen something about DevFC.exe crashing due to VMWare Workstation that listens on the same port (12000) and HTC Sync that also listens on that port. I have neither of those applications on my machine, so I am lost here. Using TCPView (from Sysinternals), I find no other application using that port.
The one thing I do notice is that [System Process] goes crazy creating connections to localhost:12000 once DevFC.exe gets started.
Anyone have some insight on this?
This might sound ridiculous but restarting your machine might solve the issue. If that doesn't work, try your project on a different machine. If the project works then there is an issue with your primary machine try uninstalling then reinstalling the Azure SDK. If the devFabric still crashes on the secondary machine then it's something related to your project.
You might want to take a look at the logs created in the DevFC folder here: %localappdata%\dftemp\DevFCLogs (C:\Users\[user]\AppData\Local\dftmp\DevFCLogs). This will hopefully shed light on the actual error (which in my case, was a conflict on port 12001. Ran netstat -ab afterwards and found it was vmware-hostd.exe. This is a service included with VMWare Workstation 8. I know you said you don't have that, but you may have some other conflicting software).
See this thread as well for more detail.
http://social.msdn.microsoft.com/Forums/en-US/windowsazuredevelopment/thread/7e205afd-4b9a-4387-8e10-99e4b8f27788
Solved the problem see the bottom of my post.
So I have a simple windows service that watches a specific folder and upploads files that come into it to a server using a web service.
It's working fine on my machine using windows 7 but when I try to start it on a windows server 2003, I receive an error: Error 1053: the service did not respond to start or control request in a timely fashion. But I get this message after only a few seconds.
I have created the ServicesPipeTimeout and set it to 60000 milliseconds.
I have tried running it from command line using sc query command and found out that the WIN32_EXIT_CODE is 0, which I think means that the service doesn´t even try to start because it find an error before it starts.
In the event viewer I get errors 7000 and 7009.
I am the Administrator on the windows server.
The only thing I haven´t tried is a hotfix I found from microsoft but I don´t want to use it because as I understand it, it is for when the service actually times out.http://support.microsoft.com/kb/886695
I have tried everything I can think of, is there anything that I am missing?
Gísli
EDIT: Re-installed the .NET framework and now I get a new error, Saying that the service controller can not be found.
EDIT: I setup the service with a setup project, not using the installutil command. This is because I need to get user input during the installation and save that in the registry.
EDIT: I have installed the .NET 4.0 framework, it wasn´t possible to install the service with out doing that.
In addition to what I wrote above I have also tried:
Rebooting.
Re-installing.
I have tried to change the permissions on the files that the service needs to access.
Changing permissions in the registry editor.
Edited the code so that the onStart function only starts one thread.
I think it is some kind of permission problem but I don´t have much experience dealing with Windows server.
Solution:
It turned out to be two seperate problems. The .NET framwork had to be repaired and I had to remove the try/catch clause that I had when starting the service. For some reason (unknown to me) the try catch block did something that made it impossible to start the service in a windows server 2003 but it ran fine on windows 7.
It would be very interesting to know why this is.
Thanks for all the help.
Gísli
Have you installed the right version of .NET Framework on the Server 2003 PC? What comes as standard on Windows 7 will need to be installed manually on an older OS.
You say "I have tried everything I can think of". Please edit the question to show what you have already tried so we don't suggest something you have already done.
EDIT:
Try also the Fusion Log viewer. Set it to log failures then start your service. Hit refresh then see if any errors are logged. Double-click a line for more details.
I'd guess that you installed the .NET 3.5 service using .NET 2.0? InstallUtil will work since the CLR is the same, but the service won't start because of .NET 3.5 dependencies.
See Also:
How to install a Windows service developed in .NET 3.5?
In your OnStart code you could wrap everything in a try-catch block and write the exception message and stack trace to a file using something like:
File.WriteAllText(#"C:\Temp\MyServiceLog.txt", exp.Message + exp.StackTrace);
This will help you analyze the problem. Also, I'm using a very simple way of debugging my services: I'm wrapping them in a WinForms wrapper if the session is interactive. For that, I need the following:
A form that creates an instance of the service class
New methods DoStart and DoStop in my service class, which are public and call the protected OnStart and OnStop methods
New code in above form's OnLoad and OnClose handlers, so the DoStart and DoStop methods of the service instance are called accordingly
Then I add the following code to the Main method in Program.cs:
if (Environment.UserInteractive)
{
Application.Run(new FormServiceHoster());
}
else
{
// ... old code to create service instance.
}
This way you're making the "service" run as an application when you just hit F5 in Visual Studio or double click the EXE in the Explorer. When the service is actually run as a service, the Forms-code is ignored.
Usually you can debug services by attaching to the process, however, that doesn't work for debugging the start and stop code. This method helps a great deal debugging the service start and stop code.
You will need to add references to System.Windows.Forms and System.Drawing manually.
This is the point where I bet you wish you had used some logging package like log4net, which might help tell how far your program gets.
Is it possible that the code in the OnStart event is actually taking longer than you expect. If so, you could move that code to a thread, so that the OnStart event finishes (and so Windows reckons the service has started) while your thread continues working.
Are you running the service as admin? If so, that usually rules out permissions issues. (If it still goes wrong, it will rule out the KB 886695 issue as that seems to only apply to local system).
Since you are using .NET 4.0 are you sure that either, the full version is installed, rather than the Client Profile, or that your application works with the client profile?
I have an (console, .NET 3.5, C#) application that I'm trying to call from a Windows Server (2003, with .NET 3.5) from a system (Windows server 2003 with .NET 2.0) via a scheduler (the scheduler app is called 24x7, it's a script based scheduler, in this case, it calls the executable strait up, no parameters, etc).
The issue is when it tries to call it, it sees it as a file and tries to "download" it. I've tried running the app from the command prompt, only to get the same results. I've tried everything I can think of, even writing a launchpad type application and using that to call the app, but I get the same results every time.
Am I missing something? Is there a security flag or something I've overlooked? I've never seen this before.
Edit: Sorry, forgot to mention that the app is being called via full UNC path (\myserver\myfolder\myapp.exe)
hmm.... how exactly are you "calling" this application? via SMB? (i.e. by executing the command \\myserver\sharepath\foo.exe from a command line)
If so, your application doesn't run with the same permissions and you can run into code access issues, but that'll come as an error message, rather than a file download.
The fact that you're getting a file download leads me to believe that you're trying to "run" the console application over http, but I don't have enough information to know for sure, hence my question.