using Matlab's mxArray gives me a typeLoadException

Hi there,

I recently moved my project, which calls a matlab dll, from VS6 to VS7.  I got it running like that ok.  Then I spent a while changing the program to use ADO .NET.  Now when I run functions with matlab stuff in them I get the following exception:

An unhandled exception of type 'System.TypeLoadException' occurred in MyProject.exe
Additional information: Could not load type mxArray_tag from assembly MyProject, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null.

The exception comes up when the code tries to step into one of the functions with matlab stuff (including mxArrays and calls to stuff in the dll).

Does anyone know what causes this?  How do I make my project know about mxArray? As far as I can recall I haven't changed the project settings, or the files with the matlab stuff in them, or anything else connected to the matlab.  But I guess my memory is failing me or something, 'cause it was definitely working before, and it isn't now.

Thanks for your help.
wilsonianAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
CetusMODConnect With a Mentor Commented:
Closed, 500 points refunded.
CetusMOD
Community Support Moderator
0
 
nonubikCommented:
>The exception comes up when the code tries to step into one of the functions with matlab stuff (including mxArrays and calls to stuff in the dll).
Does those dlls are also compiled under VS7?

>my project, which calls a matlab dll
Do you link staticaly (against .lib) or dinamicaly (LoadLibrary...) ?
I think you need a VS7 compiled version of the .lib of mathlab dll you use, if you link against it.
0
 
drichardsCommented:
>> I think you need a VS7 compiled version of the .lib of mathlab dll you use, if you link against it.
If you are referring to .lib to enable static linkage of a dll and not the .lib of a static library, then not usually, at least not with unmanaged C++ executable.  There are a few things that would force this, however.  I haven't tried a VC6 dll with managed C++ executable, so it might be different, but I wouldn't think so.

Was the new C++ a managed app before adding ADO .NET?  And what type is mxArray_tag?
0
Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

 
wilsonianAuthor Commented:
The project was unmanaged and most of it still is.  mxArray is a matlab-provided struct.
0
 
drichardsCommented:
>> The project was unmanaged and most of it still is
But you are now #using <mscorlib.dll> and "Use Managed Extensions" is "Yes" in the project properties - correct?

How are you using the mx_Array struct in your code since the compiler thinks it is a type that should exist in the managed assembly?  I'm not sure what mxArray_tag is supposed to be.
0
 
wilsonianAuthor Commented:
>But you are now #using <mscorlib.dll> and "Use Managed Extensions" is "Yes" in the project >properties - correct?
yes.

>How are you using the mx_Array struct in your code since the compiler thinks it is a type that >should exist in the managed assembly?  I'm not sure what mxArray_tag is supposed to be.

There are several mxArray pointers declared and used in functions inside a class called MatTest.  MatTest.cpp #includes the .h file of the dll, I'm guessing that's how the compiler knows it exists.
(I'm kinda fuzzy on this because I didn't write the matlab dll or MatTest)

The mxArray struct is apparently something like this:
http://www.mit.edu/~pwb/matlab/headerdump/mxinternals.h
0
 
wilsonianAuthor Commented:
Ok, that was simpler than I expected. A combination of this page:
http://www.dotnet247.com/247reference/msgs/14/72063.aspx

and this page:
http://www.mcse.ms/archive108-2003-11-115608.html

led me to the answer:  I put a line saying
struct mxArray_tag{};
in matTest.cpp, and it all worked again.
0
 
nonubikCommented:
Agree
0
All Courses

From novice to tech pro — start learning today.