   [.net] C++/CLI Class Library in C#
  Hi,I've run in a problem here when trying to use a class library made with C++/CLI (ait generates a DLL) within my C# application.I can compile the C++ DLL perfectly and I can add it as a reference in my C# application, and it finds my namespace and class name perfectly, and my C# application compiles perfectly too, but when I execute it I receive the following error:"An unhandled exception of type 'System.IO.FileLoadException' occurred in System.Windows.Forms.dllAdditional information: Não foi possível carregar arquivo ou assembly 'Criptografia, Version=1.0.2770.30376, Culture=neutral, PublicKeyToken=null' ou uma de suas dependências. Falha na inicialização do aplicativo devido a configuração incorreta. A reinstalação do aplicativo pode resolver o problema. (Exceção de HRESULT: 0x800736B1)"I've read this error is due to the inability of the C++ class library DLL to find the CLR DLLs so it could run perfectly. I've found those DLLs in the VS folder and copied to the same place but it gives me the same error again.In my machine, the program compiles and run perfectly, it is in other machines that I receive this error, even if they have VS installed or not.Any ideas of what's happening?Ty.-Roger-   
  It might be of more help to many of us if you could translate the error into English.But yes, from what you're describing, it's a common problem.  Visual C++ has DLL's associated with the release and dubug C++ Runtime Libraries.By including the C++ assembly into your C# application, it now requires those same DLL's.  You can see which modules you need by setting a breakpoint in the application on your machine and then opening up the "Modules" window in the debugger.Here you can get a list of all of the dll's that have been loaded by your application.  Any of them not part of the .NET Framework or the Operating system are going to need to be redistributed with your application.Cheers!   ;  Oh truly sorry, I didn't see the error was in portuguese. Let me translate it:"An unhandled exception of type 'System.IO.FileLoadException' occurred in System.Windows.Forms.dllAdditional information: Unable to load file or assembly 'Criptografia, Version=1.0.2770.30376, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Failed to initialize the application due to incorrect configuration. Reinstalling the application may solve the problem. (HRESULT Exception: 0x800736B1)"okay. When running my program and displaying modules, I got the following dependencies:mscorlib.dllMicrosoft.VisualStudio.HostingProcess.Utilities.dllSystem.Windows.Forms.dllSystem.dllSystem.Drawing.dllMicrosoft.VisualStudio.HostingProcess.Utilities.Sync.dllWindowsApplication1.vshost.exeSystem.Data.dllSystem.Deployment.dllSystem.Xml.dllWindowsApplication1.exeCriptografia.dllmsvcm80.dllSystem.Configuration.dllExcluding the .NET ones (System.* , Microsoft.*) and my application files (WindowsApplication1.vshost.exe, WindowsApplication1.exe and Criptografia.dll, which is my C++ DLL), it leaves me only with mscorlib.dll and msvcm80.dllI already tried to run my app in the other computer with those 2 files in the same folder as the criptografia.dll and the application was running, but no success. I need to have the msvcm80.dll in the WinSxS folder? I need to register the DLL? With the exact same name as here? The computer which I'm running the DLL and it is failing have VS 2005 but without SP1, and I have here the same VS2005 but with sp1.The path for those 2 files in the modules window are:mscorlib.dllC:\WINDOWS\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dllYesN/ACannot find or open the PDB file.12.0.50727.42 (RTM.050727-4200)19/7/2007 14:39790C0000-79BA6000[1988] WindowsApplication1.vshost.exe: Managedmsvcm80.dllC:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700\msvcm80.dllYesN/ASymbols loaded.C:\WINDOWS\symbols\dll\msvcm80.i386.pdb138.00.50727.7621/8/2007 15:507C540000-7C63A000[1988] WindowsApplication1.vshost.exe: ManagedI saw the other PC didn't had the C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_6b128700\ folder, only had similar ones, so I copied this folder and contents to the other PC, but nothing happened as well....What I need to do to get the C++/CLI Class Library DLL to work properly?Ty. -Roger-;  Did you install the visual c++ runtime on the other machines? ;  Sorry for being out for a while, I had some problems with my machine here at work and I couldn't test anything else (those IT morons destroyed our network) Alas..Well, I've installed the VC++ Runtime in the other machine but the class library didn't work as well. It should be no problem as the other machine has the VS 2005 installed too, but even with the runtime it didn't worked, the error persisted.:(;  No one??? No idea of what I can do to solve this? :(   ;  C'mon ppl, I can't believe no one can help me with this.....It is urgent, I'm really stuck with it, and I really need this badly....NO one have the slightest idea of what is going on?:(   ;Quote:Additional information: Unable to load file or assembly 'Criptografia, Version=1.0.2770.30376, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Failed to initialize the application due to incorrect configuration. Reinstalling the application may solve the problem. (HRESULT Exception: 0x800736B1This error implies that the culprit is your own assembly (Criptografia). It cannot be found when the Application object (which is in the Windows.Forms assembly) attempts to call some code that requires it to be loaded -- something tries to load it, and fail. This could be because the dependancies couldn't be loaded, but the obvious thing to check first is that the assembly exists next to the .exe when you're trying to run it?If it does, you want to check what dependancies Criptografia has and what dependancies your application has. Chances are, they depend on different versions of something and you'll need to change one.;  Yeah, it is in the same directory as my .EXE program. When I add its reference in the machine that gives me this error (any machine different than mine), it copies the DLL to the debug/release folder in order to run it. I also tried copying manually the DLL, and both gives me the error.   ;  You could double-check what dependencies the program has by downloading the depencency viewer: www.dependencywalker.comAnd try running the fusion log viewer (fuslogvw) to see if that gives you any more info.-Edit- Actually, the FileLoadException has a FusionLog property - what's the value of this property on the exception being thrown?Cheers,gary   