Cocould not load file or assembly '...' or one of its Dependencies. the application fails to start because the application configuration is incorrect...
The two projects are. the C # And C ++ and C ++ projects under net2005 use C ++/CLI to encapsulate several functional functions and load and use encapsulation classes in the C # project. The exception dialog box appears when running normally locally but is released to other machines: "cocould not load file or assembly '...... 'or one of its dependencies. the application cannot be started because the application configuration is incorrect. Re-installing the application may correct this problem. (Exception from hresult: 0x800736b1 )".
This error seems to be a problem with the c ++ dll library. Because the hybrid mode is used to compile the hosted DLL, the DLL will use the unmanaged CRT (C Run-Time) Library. If these runtime components are not installed on the machine, an error similar to hresult: 0x8007 is generated. The simplest method is to download and install Microsoft Visual C ++ 2005 redistributable package (x86) to obtain the msvcr80.dll and msvcm80.dll required for code running; you can also find the MSM file containing the CRT in the Program Files \ common files \ merge modules directory on the system disk, and add these files to your installer to achieve the same effect; if C ++ generates executable files instead of DLL files, you can copy the required DLL files to the application directory according to Microsoft's instructions. For more detailed analysis instructions, see bootstrapper for the VC ++ 2005 redists (with MSI 3.1 ).
Note that if you use DEBUG configuration when compiling the C ++ hosted assembly, the generated dll must call the debug version corresponding to the CRT (msvcr80d. DLL and msvcm80d. DLL) instead of the files in the above redistributable package. In this way, even if you use any method to install those Runtime library files, the error exception dialog box will still be displayed. To understand whether the generated DLL is debug or release, you can use a text editor to open the DLL file and find the following similar content (usually at the end of the file ):
View plaincopy to clipboardprint?
- <Assembly xmlns = "urn: Schemas-Microsoft-com: ASM. V1"
- Manifestversion = "1.0">
- <Dependency>
- <Dependentassembly>
- <Assemblyidentity type = "Win32"
- Name = "Microsoft. vc80.debugcrt"
- Version = "8.0.50608.0"
- Processorarchitecture = "x86"
- Publickeytoken = "1fc8b3b9a1e18e3b">
- </Assemblyidentity>
- </Dependentassembly>
- </Dependency>
- </Assembly>
<Assembly xmlns = "urn: Schemas-Microsoft-com: ASM. v1 "<br/> manifestversion =" 1.0 "> <br/> <dependency> <br/> <dependentassembly> <br/> <assemblyidentity type =" Win32 "<br/> name = "Microsoft. vc80.debugcrt "<br/> Version =" 8.0.50608.0 "<br/> processorarchitecture =" x86 "<br/> publickeytoken =" Courier "> <br/> </assemblyidentity> <br /> </dependentassembly> <br/> </dependency> <br/> </Assembly>
If you seeMicrosoft. vc80.debugcrtIt indicates that the DLL link is the debug version of CRT.Microsoft. vc80.crtLink to the redistribution version. When I am in. when the net2005 ide generates C # EXE and C ++ DLL through batch generation, if the current active solution configuration is debug, the C # project's release output directory copies the C ++ DLL debug version file instead of the release version! Therefore, it is quite necessary to confirm the version of the corresponding file after the release is generated.
Another possibility is that if your hard disk partition is in FAT32 format, when compiling C ++ DLL, vs.net may fail to correct manifest information due to timestamp calculation errors (basically the xml configuration information mentioned above) writing to the DLL results in a loading error because the correct dependency information is not obtained during the program running. So if the above operation still cannot solve the error, choose "properties"> "configuration properties"> "configuration tools"> "general" and set "use FAT32 solution" to "yes ".