.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
MarieAdela
Imran Ghani
Post New Web Links

DllImport of 32-Bit dlls

Posted By:      Posted Date: August 28, 2010    Points: 0   Category :.NET Framework
 
Hi guys, I am a real newbie on 64-Bit progr. so my question might sound a little stupid. I have a VB.NET project which refered to a 32-Bit dll via COM-Interop. I migrated the project and the COM invocation does not work anymore. I tried several compiler settings (anyCPU, x86) but nothing helped. Then I found in my old C# book a method called DllImport (System.Runtime.InteropServices) I declared the dll as follows: <DllImport("fcvb.dll", CharSet:=CharSet.Auto)> _ Function dllBIN2_iv(ByVal price_u As Double, ByVal ex As Double, ByVal d_exp As Double, ByVal d_v As Double, ByVal price As Double, ByVal rate_ann As Double, ByVal acc_rate As Integer, ByVal cost_hldg As Double, ByVal acc_cost_hldg As Integer, ByVal option_type As Integer, ByVal iter As Integer, ByRef return_vlty_imp As Double) As Integer End Function When calling the Dll I got f... in the middle of the process saying: errMsg = "System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)   at Wcr_.NET_2005.Module1.dllBIN2_iv(Double price_u, Double ex, Double d_exp, Double d_v, Double price, Double rate_ann,... I am running an AMD64-Bit Opteron with 2GIG of Mem on Windows Server 2003 (64-Bit) Standard. Visual Studio 2005 Team Edition for SW Developers and .NET Framework 2.0   Any comments welcome I am open for both a COM wrapper .NET dll or n


View Complete Post


More Related Resource Links

C++ at Work: Create Dynamic Dialogs, Satellite DLLs, and More

  

This month Paul DiLascia teaches readers the right way to create dynamic dialogs, explains satellite DLLs and discusses language resource DLLs.

Paul DiLascia

MSDN Magazine September 2006


.net DLLs not secure

  

.net DLLs are not secure, this is such a disappointment. 


What can one do to secure DLL apart from obfucation (which is nothing about making DLL secure)

I know that I can build a DLL in vb6 or Delphi (thats secure) and then COM (tlbimp.exe) it for .net using interlop tools for .net

ref:http://msdn.microsoft.com/en-us/library/dd233112.aspx

BUT I dont want to that, I want to stay with .net (vb) , so can anything be done to truely secure a .net DLL ??

This is very important

MSVS 2005 ASP.net 2.0 vb.net 2




AppDomain to Load and Manage DLLs

  
My question/situation is with regard to AppDomain.CreateInstanceFrom or AppDomain.CreateInstanceFromAndUnwrap or AppDomain capabilities.My customer wants a service (or application) that can invoke Public methods from any .NET Managed DLL and be able to add, change, rename, delete those DLLs out of their storage location while the service is running.  DLLs will mostly likely not be marked Serializable and will most likely not inherit from MarshalByRefObject.  Presently, I am providing this functionality without the ability to change, rename, or delete DLLs while the service is running by loading the DLLs at service start (not very memory friendly).Could I create a manager class that supports this functionality, load that class into a separate AppDomain, invoke methods as needed, and unload the AppDomain as needed when DLLs change?  I would manage execution with a Queue object to ensure that requests for invocation don't get lost and don't try to access the manager when it is no longer in scope.  A FileSystemWatcher would handle unloading the AppDomain when changes occurred.Does this sound correct, normal, abnormal, or not possible?Software Developer, Augusta Systems

dllimport("mapi32.dll") changes the path context of application (i.e. relative paths start pointing

  
I have a WPF desktop application. We use mapi32.dll to show a new outlook mail window to allow user to send an email. After user sends email / just closes the new mail window without sending email, relative path starts pointing to C:\Program Files\Microsoft Office\Office12. I have office 2007 installed.  How can I restore this relative path ?   Thanks & Regards, Nadeem Ullah

Error while trying to register DLLs for Microsoft Jet on Windows Server 2008 R2 64bit

  
Hello! I'm having issues with importing Excel spreadsheets into Microsoft SQL Server 2005 on a Windows Server 2008 R2 64bit server.  After browsing the web, it appears that the problem is with the DLL's used by Microsoft Jet.  I've thus attempted to re-register these DLL's.  However, I am receiving the following results. c:\Windows\SysWOW64> regsvr32 c:\Windows\SysWOW64\msjetoledb40.dllSuccessful c:\Windows\SysWOW64> regsvr32 c:\Windows\SysWOW64\msjet40.dllSuccessful c:\Windows\SysWOW64> regsvr32 c:\Windows\SysWOW64\msjint40.dllThe module "msjint40.dll" was loaded but the entry-point DLLRegisterServer was not found c:\Windows\SysWOW64> regsvr32 c:\Windows\SysWOW64\msjter40.dllThe module "msjter40.dll" was loaded but the entry-point DLLRegisterServer was not found c:\Windows\SysWOW64> regsvr32 c:\Windows\SysWOW64\msjtes40.dllSuccessful c:\Windows\SysWOW64> regsvr32 c:\Windows\SysWOW64\mswstr10.dllThe module "mswstr10.dll" was loaded but the entry-point DLLRegisterServer was not found I've set the application pool for this site to use 32bit.  Please note that due to my role on the team, other options such as using ACE are not available to me, unless I can prove that I've exhausted all other options. Thoughts? Thanks,Mike

How can I restrict runtime to look for dlls in only bin folder

  
Hi, How do I restrict runtime to see only bin folder to load two specific dlls To explain the scenario better, I need my windows application to communicate with MQ server. But my constraint is that I do not want the users of the application to load MQ Client. For this I extracted two dlls from MQ client and included in my project's bin folder and tried to conect to MQ server. It works perfectly fine if there is no MQ Client installed on the machine. But if any version of MQ Client is present on the machine, it fails. I believe it is trying to read from the dlls present on the machine instead of reading it from bin folder and it fails for some of the older version which did not supported .NET calls. I would want to restrict the runtime to read only two dlls and not go to load other dlls if it finds MQ Client installed.   Can <assemblybind> or probing method help me in this? If so, how to include it in my config file.          

How to restrict runtime to load dlls from bin folder only and not look elsewhere

  
Hi, How do I restrict runtime to see only bin folder to load two specific dlls To explain the scenario better, I need my windows application to communicate with MQ server. But my constraint is that I do not want the users of the application to load MQ Client. For this I extracted two dlls from MQ client and included in my project's bin folder and tried to conect to MQ server. It works perfectly fine if there is no MQ Client installed on the machine. But if any version of MQ Client is present on the machine, it fails. I believe it is trying to read from the dlls present on the machine instead of reading it from bin folder and it fails for some of the older version which did not supported .NET calls. I would want to restrict the runtime to read only two dlls and not go to load other dlls if it finds MQ Client installed.   Can <assemblybind> or probing method help me in this? If so, how to include it in my config file.        

Project dependency / reference and 3rd party dlls missing

  
hi,i'm having the same problem in multiple solutions and i asked for help in a couple of "forums" already.... here is an easy explaination about my problem.we have 3 projects:Project "A" - a web applicationproject "B" - class libraryproject "C" - class libraryProject C holds a reference to a 3rd party dll. let's say thirdparty.dll. the 3rd party dll is referenced in the C.csproj file with a relative path and private = true (copy local = true): <Reference Include="ThirdPartysNameSpace.BlaBla, Version=1.2.3.4, Culture=neutral, PublicKeyToken=0912345678910123, processorArchitecture=MSIL"> <SpecificVersion>False</SpecificVersion> <HintPath>..\_tools\thirdparty.dll</HintPath> <Private>True</Private> </Reference> Project B holds a project to project reference to Project C.Project A holds a project to project reference to Project B.when i compile project C the thirdparty.dll is copied to its bin directory. C's bin directory contains C.dll and thirdparty.dll - correct so far.however when i then compile project B the thirdparty.dll isn't copied to project B's bin directory! B's bin only contains C.dll and B.dll. why isn't project C's bin content copied to B's bin?(sure thirdparty.dll is also missing in project A's bin directory.

sqlserver clr with referenced dlls

  
where can i find a good step by step introduction for creating a sqlserver clr sp which is referencing dlls like mappoint. I understand and can follow up the helloworld example which works well. Then i modified the class calculating the distance between 2 hardcoded addresses in US and adding the using directive for interop.mappoint.dll and interop.mappointutilities.dll I compiled my class: C:\windows\microsoft.net\framework\v3.5\csc /target:library c:\helloworld\helloworld.cs /r:c:\helloworld\obj\debug\interop.mappoint.dll /r:c:\helloworld\helloworld\obj\debug\interop.mappointutilities.dll The comilation runs without an error. but when i try to register the assembly in sqlconsole create assembly helloworld from c:\helloworld.dll with permission set safe (also tried unsafe) I get the error: Meldung 10301, Ebene 16, Status 1, Zeile 1 Die HelloWorld-Assembly verweist auf die interop.mappoint, version=0.0.0.0, culture=neutral, publickeytoken=null.-Assembly, die in der aktuellen Datenbank nicht vorhanden ist. SQL Server hat versucht, die Assembly, auf die verwiesen wird, am gleichen Pfad wie die verweisende Assembly zu suchen und automatisch zu laden. Dieser Vorgang ist jedoch fehlgeschlagen (Ursache: 2(Das System kann die angegebene Datei nicht finden.)). Laden Sie die Assembly, auf die verwiesen wird, in die aktuelle Datenbank, und wiederholen Sie die Anforderung. meaning thast

Differences between signed and unsigned dlls

  
Hi, Can someone brief on differences between signed and unsigned dlls. How can we test each of these ? thanks in advance sam

MSDN sample Dllimport unable to load DLL

  

Hi,

I tried out the sample described in MSDN "extern (C# reference)" (Example 2 and 3, the one which created an unmanaged dll called Cmdll.dll, then used it in cm.cs)

It doesn't work. I'm guessing path problem. Following is the error message.

Unhandled Exception: System.DllNotFoundException: Unable to load DLL 'Cmdll': Th
e specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at MainClass.SampleMethod(Int32 x)
   at MainClass.Main()

The generated dll is in the same folder as the cm.exe. I copied the dll to the System32 folder. None works.

Any help appreciated.

 


how to sign Ent Lib DLLs???

  

Hi Forum,

I have had to sign the EL5.0 DLLs for GACing and I tried out various options. Finally, I had to open the source solution in VS2008 and in the Properties window, changed the Strong name key file and compiled it. Is there any better way of doing this???

Praveen.


Praveen Behara
MCST : BizTalk Server 2006 R2

Referring DLLs in Service

  

Hi,

I am creating few WCF services. The number may be high. And we have used a pattern in each service to handle different targets. Now the issue is like each service is having 3 classes. And these three classes are similar in all sevrices with minor changes. These classes use corresponding data contracts in thier classes and the remaing logic is same. Now i am trying to reduce no of classes in each service. So I've added a class librray to solution and these classes are available in that library. And I am referring these library in each service. Since all services use this library, I am referring all data contracts in this newly created library.

My question is what is the impact of referring a dll(s) in class library. Is it ok to refer all dlls in one library and refer that library in each service? Earlier implementation is referring corresponding data contract dll in each service. Now all the data contracts are removed from services and moved to one library. Am I doing correct in terms of performance and maintainability?


DllImport and smart card

  

Hello, i have a problem with a dll.

the dll is casmcard.dll, it interface to the ez100 card reader. i'm using a sle4442 smartcard.
The manufactor gave me a simple vb project that call some function from a static class (CasAPI). It wrap the functions using the dllimport.

I am working on a c# program, so i included the project, to use the CasAPI functions. It works, since i have to change the code of a card (SLE4442_Update_Security_Memory()). The point is that it works just in the vb project, and when i call it from my project it return an error code (SCARD_E_NO_MEMORY that means "Not enough memory available to complete this command").

The vb declaration is 

Public Declare Function SLE4442_Update_Security_Memory Lib "casmcard.dll" (ByVal hCard As Integer, ByRef SendBuffer As Byte, ByVal StartAddr As Integer, ByVal SendBufferLength As Integer) As Integer

and i call it as this

response = CasAPI.SLE4442_Update_Security_Memory(mSCardContext, ref code[0], 1, 3);

code is a 4 byte array 

in vb it is called like this:

Result = SLE4442_Update_Security_Memory(CardHandle, Data(0), 1, 3)

 

There are many other functions that use the reference of the first element of the array to fill it, and i verified that they all works, so it shouldn't caused by the array.

Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend