Home > Net >  The.net framework version different DLL abnormal lead to call a third party
The.net framework version different DLL abnormal lead to call a third party

Time:09-17

I use c # 2017 version calls a third-party DLL (old Delphi development), if in the environment. Set the target framework for.net framework 4, everything is normal, but if set the target framework 4.5 or 4.7, directly to collapse, to stop work,
Reference to:

[DllImport (a. d. "ll" CharSet=CharSet. Ansi, CallingConvention=CallingConvention. StdCall)]
///return: MarshalAs (UnmanagedType. LPStr)]
Public static extern string f_b ();//no parameter is PChar


How to adjust excuse me what reason be?

Configuration manager for x86.

CodePudding user response:

Generally this kind of components and the.net version there is no relationship;

Download a dependency, search depend on the link: http://www.dependencywalker.com/

CodePudding user response:

reference 1st floor yeness response:
general this type of component and the.net version there is no relationship;

Download a dependency, depend on the associated searched: http://www.dependencywalker.com/


First thank you,
Check the DLL rely on link?
Switch all code, the environment is constant, only the target framework, is a normal operation, a collapse (tips to stop working) directly, I will melt the,,

CodePudding user response:

The.net framework version problem, not their own can solve
Alternative approach is to create a class library in 4 introduce third-party DLL, and converted to c # method
Quote above in 4.5 the project to create a DLL, always can't say that. The.net framework own DLL cannot reference too?

CodePudding user response:

reference xuzuning reply: 3/f
.net framework version problem, not their own can solve
Alternative approach is to create a class library in 4 introduce third-party DLL, and converted to c # method
Quote above in 4.5 the project to create a DLL, always can't say that. The.net framework own DLL cannot reference too?


I use 4 introduces the third party DLL generated a new DLL
But to call the new DLL, the phenomenon is the same, the target frame for the.net framework 4, everything is normal, but if set the target framework 4.5 or 4.7, directly collapse
Referenced DLL True and False have tried a particular version attribute

CodePudding user response:

You mean 4.5 cannot use 4 generated DLL
Is this meaning?
I don't have enough environment to test

CodePudding user response:

He this refers to the net to generate DLL, not netdll version of the dependency problem

CodePudding user response:

Recently met the same problem, don't know how to solve, the building Lord solved? Calls the DLL of Microsoft, is originally framework is 4.5.2, direct change frame is 4.0, and then can run under 4.0 environment, but some DLL function call is not successful, I know how to return a responsibility?

CodePudding user response:

reference 5 floor xuzuning reply:
you mean 4.5 cannot use 4 generated DLL
Is this meaning?
I don't have enough environment and can't test


Yes, I use 4 to generate a DLL can only be cut in 4, collapse into 4.5

Don't need a lot of the environment, have to do is 2015 or 2017, switch to the target frame line
If you have time to help, I can send you the original DLL
thank you

CodePudding user response:

refer to 6th floor starfd response:
he this refers to the net to generate DLL, not netdll version of the dependency problem


Yes, but I don't know what is the difference between different framework of DLL, is it possible to call way or parameter types can be solved?

CodePudding user response:

refer to 7th floor qq_36970553 response:
recently met the same problem, don't know how to solve, the building Lord solved? Calls the DLL of Microsoft, is originally framework is 4.5.2, direct change frame is 4.0, and then can run under 4.0 environment, but some DLL function call is not successful, I know how to return a responsibility?


Also in the study,,
4: sure, 4.5, 4.7 the direct stop working

CodePudding user response:

I can run, but call DLL is not successful, only in 4.5.2 with 4.6 version of the.net can normal use, I do the USB communication is to call DLL, call unsuccessful DLL couldn't connect testing on the USB device

CodePudding user response:

The building Lord my problem solved, only configuration manager can be configured to X86, the measured effective, you can have a try, to start with my configuration is Any CPU

CodePudding user response:

refer to 12 floor qq_36970553 reply:
the building Lord I problem solved, only configuration manager can be configured to X86, the measured effective, you can have a try, to start with my configuration is Any CPU


I have been set as x86

Thank you very much

CodePudding user response:

Reference 1/f yeness response:
Generally this kind of components and the.net version there is no relationship;

Download a dependency, search depend on the link: http://www.dependencywalker.com/

CodePudding user response:

.net DLL call other languages, such as c + + does not exist the.net version of the dependence difference
In addition to what you said about the X86, X64 and AnyCPU
X86 can only run on 32 of the CLR
X64 can only run on 64 CLR
AnyCPU can run on a 32-bit can run on 64 - bit, but not to say that there would be no problem using AnyCPU
If your computer is 64 bit AnyCPU will run on a 64 - bit CLR above, if you use this time has 32, tripartite DLL call will appear the phenomenon of failure
Relative if your computer is 32 AnyCPU will run on a 32-bit CLR

CodePudding user response:

Selected X86 and method return values entrance with IntPtr dephi return value into a string with pchar c # use, how to turn on baidu.

CodePudding user response:

k. reference 20 floor response:
entry selected X86 and method return values with IntPtr dephi return value with pchar when using c # to string, how baidu once line.



Positive solution!

CodePudding user response:

This problem solved? I also encountered this problem, the return value with intPtr can?
  •  Tags:  
  • C#
  • Related