Embed a win32 dll in .net Project -


Is it possible to embed a win32.dll in a .NET project? Ideally I do not want to distribute a .dll with .exe. I have read about using the AssemblyReslove for .NET DLL, but this is not working for my .dll (built with Intel Fortran compiler). First of all, "App Damman. The current dimension. Assembly Assembly" is never called. However, if I force the assembly load before using .dll, I get the following error:

In mscorlib.dll there was an unrestricted exception of 'System.BadImageFormatException' type. .
Additional information: Could not load one of the file or assembly '16896 bytes DLLtest2, version = 1.0.0.0, culture = neutral, load or its dependency from public koken = zero'. An attempt was made to load the wrong format program.

Any thoughts that I am doing wrong - or can I try?

Code assembly load:

 using  (var stream = assembly.Get accelerating (). GetManifestResourceStream ("DLLtest2.Dll1.dll")) {byte [ ] Assembly data = new byte [stream.Length]; Stream Read (Assemblidata, 0, assembly data. Lang); Assembly.Load (assemblyData); }  

Thanks!

assembly.load is for NAT. (Managed) Assemblies You only need to use PInvoke for native DLL.

  • Looking at the following (Intel) Fortran Suburban:

      Suburban Dovak (N, A)! DEC $ ATTRIBUTES DLLEXPORT :: DoWork! DEC $ ATTRIBUTES ALIAS: 'DoWork' :: DoWork! DEC $ ATTRIBUTES REFERENCE :: n, an integer, int (in) :: n real (8), dimension (n, n), int (inout) :: one end subroutine  

    Use the following method sign in the C # code. Public Definition Zero Doorke (Referee Int N, Caller Convention, Calling Convention. CDEcl). [DllImport ("FortranStuff .dll", EntryPoint = "DoWork", Charset = CharSet.Ansi, [These, out] double [,] A);

    In this example, FortranStuff.dll should be in the same directory as the calling assembly. You can modify the attribute to use a relative or full file path (".. .. \ bin \ FortranStuff.dll"), but I only recommend placing it by the side to reduce confusion.


    Comments