I am trying to develop a native (CPP) IIS 7.5 module that will handle a specific type of request using visual studio 2010 and I am having a heck of a time. The library builds correctly however it appears IIS is never calling RegisterModule.
Things I have verified:
The module is listed in globalModules and modules.
The library looks all good from dependency walker and has no missing dependencies.
Built the library as a Win32 release DLL.
Verified the definition file is correct.
I build the IIS7NativeModule provided by Microsoft and it also gets the same errors.
The error generated by IIS is as follows:
HTTP Error 500.21 - Internal Server Error
Handler "URLModule" has a bad module "IIS7NativeModule" in its module list
My end goal is to provide a URL such as "/track?code=testing123" and respond either with an error message or redirect the user to a specific URL based on the GET code.
Any thoughts / advice, etc?
Thanks!
Nate
Related
I working on an ATL Service project, an exe (out of process) NOT a DLL, and have created my COM object. When I test the Server in Visual Studio 2015 with a test client application it works with no problems.
When I install the server using, as recommended by MSDN,
YourEXE.exe /Service
The server installs and is visible in Services however when I use the same test client application I get the REGDB_E_CLASSNOTREG Class not registered error (Please note Question does not solve this).
Any ideas on a potential problems? I have only added the COM object and have not modified the rest of template in anyway. Have I possibly missed something?
We found the problem. The .rgs file had the wrong GUID in it.
This is unusual as the file was auto generated.
I am using a already developed C++ dll in my asp.net code to make compression/decompression of the data. It works well on my developer machine and some other machines too. I have a client machine which is fresh(No fancy installation of various tools) and When it tries to call that dll it generates an exception.
Exception:Could not load file or assembly 'dllcode, Version=1.0.5754.25819, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
I would like to know that which dependencies are missing on Client fresh machine?
Note: I am trying to call C++ dll in a windows service which is having asp.net 4.0 framework. This call is executing perfectly on my developer machine but generates above exception on my client machine.I do not have deep knowledge about c++ library and it's dll. From basic troubleshooting I tried to install various combinations of "microsoft visual c++ 2010 runtime" but it did not help.
Update: Somehow I find source code of this C++ dll and now I am trying to check if I can build this dll any version specific.
I got this resolved. What I did is, I had to create separate setups(32-Bit & 64-Bit). Also VC++ run time was needed on server. So I installed them and it worked.
Hope this help to any one if he faces the same issue.
I am having a few troubles with a set of hosted code on an WS2K8 R2 box with IIS 7. I have another server running WS2008 that does not encounter the same issue. I have copied the application code from the old server so that it is identical.
The exception thrown in my server side logs is:
"ModuleLoadException: The C++ module failed to load while attempting to initialize the default appdomain."
I also have an error being returned in VS2010 at the same time:
Unable to find assembly 'msvcm80, Version=8.0.50727.4927, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
I have checked and the correct version of msvcm80 is on the server in the "C:\Windows\winsxs" folder. I have also installed Microsoft Visual C++ 2005 Redistributable (x64) and (x86).
I cannot see why the error might be thrown??
My debugging expierence is low so please bear with me.
I re-checked the version details. It appears that it was a requirement of the Microsoft Visual C++ 2005 Redistributible. I re-installed all versions of it on the server and applied the security hotfixes.
After a re-boot and testing in IIS the issue has now gone from my log files.
I did check the comparison between the two servers and wasnt that happy copying the files over. I felt it was best to try this method first.
Thanks for your help.
msvcm80 is a .NET Framework mixed assembly (microsoft visual c++ managed + unmanaged). You might try to find this file on the second server and place near your application on the first server machine.
Note: .Net Framework Runtime requires exact version of an assembly (8.0.50727.4927 in your case).
I obtained some code from a friend, developed on the same system (Windows 7) and same Visual Studio Ultimate 2010, with all the libraries relatively mapped.
The code builds, but when trying to run it I get the error:
Application failed to start because the application configuration is incorrect"
Running Dependency Walker on the executable showed that msvcr90.dll, ieshishm.dll, ieframe.dll and freeglut.dll could not be found. I copied these to the execs directory and that solved these problems. However, two issues remain:
Error: The Side-by-Side configuration information for "e:\projects\darwin\code\debug\GLTEMPLATE.EXE" contains errors. The application has failed to start because its side-by-side configuration is incorrect. Please see the application event log or use the command-line sxstrace.exe tool for more detail (14001).
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.
With SHLWAPI.DLL and IEFRAME.DLL modules being marked red (assuming error message relates to these two, how do I fix that?).
Also, the sxstrace gave following result:
Begin Activation Context Generation.
Input Parameter:
Flags = 0
ProcessorArchitecture = x86
CultureFallBacks = en-US;en
ManifestPath = E:\Projects\Darwin\Code\Debug\GLTemplate.exe
AssemblyDirectory = E:\Projects\Darwin\Code\Debug\
Application Config File =
INFO: Parsing Manifest File E:\Projects\Darwin\Code\Debug\GLTemplate.exe.
INFO: Manifest Definition Identity is (null).
INFO: Reference: Microsoft.VC90.DebugCRT(...)
INFO: Resolving reference Microsoft.VC90.DebugCRT
INFO: Resolving reference for ProcessorArchitecture x86.
INFO: Resolving reference for culture Neutral.
INFO: Applying Binding Policy.
INFO: No publisher policy found.
INFO: No binding policy redirect found.
INFO: Begin assembly probing.
INFO: Did not find the assembly in WinSxS.
INFO: Attempt to probe manifest at C:\Windows\assembly\GAC_32\Microsoft.VC90.DebugCRT\9.0.21022.8__1fc8b3b9a1e18e3b\Microsoft.VC90.DebugCRT.DLL.
INFO: Attempt to probe manifest at E:\Projects\Darwin\Code\Debug\Microsoft.VC90.DebugCRT.DLL.
INFO: Attempt to probe manifest at E:\Projects\Darwin\Code\Debug\Microsoft.VC90.DebugCRT.MANIFEST.
INFO: Attempt to probe manifest at E:\Projects\Darwin\Code\Debug\Microsoft.VC90.DebugCRT\Microsoft.VC90.DebugCRT.DLL.
INFO: Attempt to probe manifest at E:\Projects\Darwin\Code\Debug\Microsoft.VC90.DebugCRT\Microsoft.VC90.DebugCRT.MANIFEST.
INFO: Did not find manifest for culture Neutral.
INFO: End assembly probing.
ERROR: Cannot resolve reference Microsoft.VC90.DebugCRT,processorArchitecture="x86",publicKeyToken="1fc8b3b9a1e18e3b",type="win32",version="9.0.21022.8".
ERROR: Activation Context generation failed.
End Activation Context Generation.
(...)
And some more similar.
I also tried changing the runtime library as suggested on other related posts from multi-threaded debug DLL (/MDd) into multi-threaded debug (/MTd). However, I get the:
MSVCRTD.lib(MSVCR100D.dll) : error LNK2005: _printf already defined in LIBCMTD.lib(printf.obj)
And some five more similar. Excluding LIBCMTD.lib allows me to build. However, I still cannot run the application. I get the same error as in the very beginning.
What is going wrong and how do I fix this?
No other related posts gave me the answer so far.
Your project uses one or more libraries that were built with Visual Studio 2008, the previous version of Visual Studio. They require the C runtime library for that version to be available; that's why it is complaining about msvcr90.dll. You've got Visual Studio 2010; you only have msvcr100.dll installed on your machine.
Just copying msvcr90.dll isn't going to work; that DLL needs to be installed in the Windows side-by-side cache. You can get an installer from Microsoft or from your friend. That's, however, not the true fix; you still have a problem with your application depending on two versions of the CRT. Very unhealthy, that can cause very-hard-to-diagnose crashes and memory leaks. You need to get the libraries rebuilt with Visual Studio 2010. That's where my advice fizzles out; I can't guess what those libraries are from your question.
"msvcr90" <- I'm pretty sure that's not the 2010 version; not the release anyway. My bet is that somewhere in the mix you're linking to something built against an older runtime but not old enough to be installed with win7.
You don't want to switch to the static runtime while linking to 3rd party DLL's, or your own DLL's.
It is possible the problem in manifest.
I set Configuration Properties/Linker/Manifest file/ Generate manifes==No
and program began starting.
Creating a WCF Service Library in Visual Studio 2008 on Vista x64 is troublesome when referencing an x86 DLL. A service that calls a 32-bit DLL is required to have a platform target of x86 to run on a 64-bit OS. When you do this, the WcfSvcHost throws a BadImageFormatException when you attempt to debug the service. There is a bug report on MS connect. The workaround I used was to coreflag WcfSvcHost as 32-bit.
Manifest Problem
The main issue I've run in to is this third-party native 32-bit DLL fails to load using certain WCF hosts. I receive the following error when a service operation is invoked that uses the third-party DLL:
System.TypeInitializationException: The type initializer for
'' threw an exception.
.ModuleLoadExceptionHandlerException:
A nested exception occurred after the
primary exception that caused the C++
module to fail to load.
System.BadImageFormatException: The module was expected to contain an
assembly manifest. (Exception from
HRESULT: 0x80131018)
NestedException:
The handle is invalid. (Exception from HRESULT: 0x80070006 (E_HANDLE))
This exception is not raised when WcfSvcHost starts, it's raised when the a service operation is invoked that references the 32-bit DLL. What's very interesting, hosting this same service with the same app.config on a console app has no exceptions and works perfectly:
using (ServiceHost host = new ServiceHost (typeof (MsgBrokerService))) {
host.Open ();
Console.WriteLine ("running");
Console.ReadLine ();
This exception occurs right after:
'WcfSvcHost.exe' (Managed): Loaded
'C:\Windows\WinSxS\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.3053_
none_d08d7bba442a9b36\msvcm80.dll'
Again, the console app does not have an exception and loads the same DLL:
'ConsoleApp.vshost.exe' (Managed):
Loaded
'C:\Windows\WinSxS\x86_microsoft.vc80.crt_1fc8b3b9a1e18e3b_8.0.50727.3053_
none_d08d7bba442a9b36\msvcm80.dll'
See answer from Microsoft Product Support.
Update #1: Both the console application and the WcfSvcHost.exe host process runs under the same session and logged-in user (me). I've copied WcfSvcHost.exe to the directory of the service, manually launched and experienced the same result. I've also checked the Windows Event Log for additional information and used sxstrace, but nothing was logged.
Running Process Explorer, I've verified the following are the same between the two processes:
Image: 32-bit
Current Directory
User/SID
Session
Security (groups denied, privileges disabled)
Running Process Monitor, and configuring symbols, I see WcfSvcHost looks for the following registry and files, while the console host does not. Process Monitor logs a lot of data and I'm not sure what I'm looking for :(.
HKLM\SOFTWARE\Microsoft\Fusion\PublisherPolicy\Default\policy.8.0.msvcm80__b03f5f7f11d50a3a
C:\Windows\assembly\GAC_32\msvcm80\8.0.50727.3053__b03f5f7f11d50a3a
C:\Windows\assembly\GAC_MSIL\msvcm80\8.0.50727.3053__b03f5f7f11d50a3a
C:\Windows\assembly\GAC\msvcm80\8.0.50727.3053__b03f5f7f11d50a3a
Update #2: This same exception occurs when the service is hosted in production on IIS 6 / Windows Server 2003.
Update #3: The 3rd-party 32-bit .NET assembly is the StreamBase API:
sbclient.dll (managed)
monitor.netmodule (managed)
dotnetapi.dll (unmanaged)
pthreads-vc8.dll (unmanaged)
Update #4: Added manifests without success:
Verified that dotnetapi.dll and pthreads-vc8.dll have RT_MANIFEST. The sbclient.dll .NET assembly did not have a manifest
Removed sbclient.dll from the GAC
Registered sbclient.dll for verification skipping
Added a manifest via mt.exe to both sbclient.dll and monitor.netmodule
Verified manifest was added and that the expected files were loaded during testing (via Visual Studio - debug modules window)
The same BadImageFormatException is thrown under BackgroundWorker.OnDoWork(), and the call stack shows a call to dotnetapi.dll...DefaultDomain.Initalize().
I have verified that msvcm80.dll does not have a manifest, I believe this is the only file loaded that doesn't have a manifest :)
Interesting find
When I load monitor.netmodule in Reflector, it says:
'monitor.netmodule' does not contain
an assembly manifest.
Even though it displays an error, Reflector is still able to disassemble the managed code.
a bit late but you can also change the app pool setting "Enable 32-bit Applications" to true in advanced settings.
Microsoft Product Support has resolved this question: It's by design. The unmanaged code is not loaded in the default AppDomain when using WcfSvcHost or the IIS WCF host.
A pure image will use a CLR version of
the C run-time library. However, the
CRT is not verifiable, so you cannot
use the CRT when compiling with
/clr:safe. For more information, see C
Run-Time Libraries.
http://msdn.microsoft.com/en-us/library/k8d11d4s.aspx
I cannot provide an explanation for the error, only my initial suspicion that there is a permission difference between the context in which your code is run as a service and the context in which it is run when you place it in a console application. The E_HANDLE HRESULT is my clue here. Assuming that you run the console application as your logged-in user, you could try configuring the service to start as that user as well. If it works in that configuration, then you can attempt to narrow down what required resource is unavailable when it fails.
I can suggest a workaround. If there is an oddity of the DLL in question that prevents it from working in a hosted service, you can take the sacrificial process approach, so named because it is typically used to isolate a DLL that crashes often. Briefly, you create a proxy program whose only purpose is to load and call the DLL on behalf of your main process, using named pipes or some other IPC method to pass requests and results. If the DLL crashes, you start a new instance of the proxy program. In your case it would have the added benefit that only the wrapper program would need to be 32-bit.
Do you see anything special in the Event viewer?.
In Vista if there a manifest problem you will see traces of it in the Event Viewer, it will tell you to use SxsTrace.
Could you manually add a manifest to this DLL yourself, using the mt.exe file?
MSDN Article on using mt.exe
This may seem a bit dumb; but make sure your service is running in the correct application pool.
Ran into this issue myself. I found a helpful post. As noted in other posts, Microsoft stated this is by design. Basically you need to:
Locate your version of WcfSvcHost.exe. (for me and visual studio
2017: C:\Program Files (x86)\Microsoft Visual
Studio\2017\Professional\Common7\IDE)
Launch developer command prompt
Execute cmd: copy C:\SourcePath\WcfSvcHost.exe
C:\DestinationPath\WcfSvcHost32.exe (Destination doesn't matter)
cmd: corflags /32BIT+ /Force WcfSvcHost32.exe (may need to cd to DestinationPath
In visual studio open the WCF project properties > Debug tab > Start External program: C:\DestinationPath\WcfSvcHost32.exe
Also add your command line arguments:
/service:MyWCFProjectName.dll
/config:MyWCFProjectName.dll.config
Note: You do not need to use ($ProjectDir) here
Launch the app. You are now free to launch WcfServiceHost.exe seperately.
Optionally go to solution > Set Startup Projects > Multiple Startup Projects > Choose the Wcf project and the client project.