We help IT Professionals succeed at work.

vb.net framework versions

1,028 Views
Last Modified: 2014-05-28
I have a DLL and VB.NET source code from NIST called REFPROP that work under .NET Framework 3.5. At the same time, I have an application I need to build that uses third party controls from National Instruments that only work under .NET Framework 4.0.
The main application (framework 4.0) contains all of the UI and other functions I need with the exception of calls to the NIST REFPROP to get refrigerant properties.
I am trying to find a way to use the main program (using framework 4.0) to call a second program (the NIST REFPROP using framework 3.5) to get the answers I need.
Typically, you pass a temperature and pressure and refrigerant type to the RefProp routine with a function call for the answer you want and the function result provides the answer.

I am at a loss as to what to do here. Any suggestions?

Thanks,
Charlie
Comment
Watch Question

Senior Software Engineer
CERTIFIED EXPERT
Top Expert 2009
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
I set the program to Framework 4 and when it reaches this line:

Call SETUPdll(nc2, hfld, hfmix, hrf, ierr, herr, 10000, 255, 3, 255)

I get an error: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

However, if I change the program to Framework 3.5, re-launch it and run it again, not only do I not get any errors, it gives me the correct answer.

Any ideas?

Thanks,
Charlie
Miguel OzSenior Software Engineer
CERTIFIED EXPERT
Top Expert 2009

Commented:
Could you send the method declaration of SETUPdll? I need to see what kind of classes/primitive types or heaven forbids COM/Unmanaged code.
It seems that you are dealing with COM/Unmanaged code. A typical .NET assembly will not raise such an error. also you need to check whether your build is 32 bits (x86) or 64 bits.
You may have some differences especially if you are dealing with unmanaged code. One quick fix could be to create a facade class that is contained in a .NET 3.5  assembly. This class will encapsulate any interaction and calls to any .NET 3.5 code so that your program only interacts with this class only, not your third party DLL.

Author

Commented:
I don't have access to the source code of the third party DLL.
If I understand what you are suggesting, I should take the vb.NET module that works under NET 3.5 and create a DLL from that. Then my NET 4 4 program would call the new DLL I make and that in turn calls the functions in the third part DLL.

Do I understand this correctly?
Miguel OzSenior Software Engineer
CERTIFIED EXPERT
Top Expert 2009

Commented:
Perfect. Just make sure you have the same build properties as per .NET 3.5 project

Author

Commented:
I have not done this in a long time (and not that many times at that) can you assist me with creating the new DLL from the module?
I think I need to launch a new instance of VB.net and "New Project" and select "Class Library". (being sure that it is Framework 3.5)

Then, in the code window I would copy the entire contents of the existing module (with the exception of "Module General" and "End Module" and then save the new Class project in its own folder.

I would then start a new program (windows Form) and to that I would need to add the Class Library reference by browsing for it.

Do I have this right so far?
Miguel OzSenior Software Engineer
CERTIFIED EXPERT
Top Expert 2009

Commented:
Yes, that is correct just make sure that the "class" declaration has no unmanaged code dependencies.
For example declaring pointers as parameters in a method.
Also check if there is any start-up and closing methods that setups your library usage and surface them as shared methods(static in C#) in case the third party library requires a special initialization and resource clean-up respectively.
Other than that it should work as advertised.
Ess KayEntrapenuer
CERTIFIED EXPERT

Commented:
Can you create the 3.5 app As a DLL file, and just reference it inside the 4.0 Program or vica versa?

Author

Commented:
That is what I am going to attempt to do. So I will have a 4.0 program that makes calls to a 3.5 DLL that makes calls to a DLL probably created by some Fortran code. (I have no idea what NIST is using today) It would be a lot easier if I had the source code for the DLL from NIST
Ess KayEntrapenuer
CERTIFIED EXPERT

Commented:
Whats this for, NASA?



Maybe this example will help you make calls to the dll

http://communities.ptc.com/docs/DOC-5177


Best mode of action is just add the dll to your resources, and send calls to it.

Author

Commented:
The problem is, the NIST REFPROP dll will not work wih a Net 4.0 Framework program
Ess KayEntrapenuer
CERTIFIED EXPERT

Commented:
then make a 3.5 dll with it, call all functions,  return the returns,  then add that dll to your 4.0
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.