Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / September 2005

Tip: Looking for answers? Try searching our database.

assembly load error (InterlockedExchange64 issue)

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mikanu - 26 Sep 2005 17:42 GMT
Hi,

I'm developing an assembly that contains a managed class and an unmanged
class. The managed class contains an instance of the unamanged class.
Basically, the managed class is a wrapper for the unamanged code.

The problem is that once I started using the InterlockedExchange64 function
inside the unmanaged class code the assembly stoped working. It still
compiles but it can't be loaded by client applications. I can still browse it
with the Object Browser if added as a reference in my client application but
when the application starts I get a System.IO.FileLoadException which seems
to be related to the line of code that attempts to create a new instance of
the managed class.

Also I've tried to open the assembly in the "Evaluate Assembly" tool from
the .NET Configuration Utility Suite in order to a.ses whether or not this
was a security policy issue but the Evaluate Assembly tool gives me an error
stating that the assembly could not be loaded.

Another interesting issue is that I can't use the plain InterlockedExchange
function in the unamanged code becuase it is not available. Only the
InterlockedExchange64 version... I found that to be a bit intriguing.

I'm compiling the code on a machine running WinXP SP2, using Visual Sution
.NET 2003, on the .NET framework 1.1. Also, I have installed on the machine,
the .NET framework 2.0 beta.

Any help will be greatly appreciated. Please feel free to ask more questions
if the description of this problem isn't satisfactory.

Signature

Mikk,
mikkanu@community.nospam

Willy Denoyette [MVP] - 26 Sep 2005 22:54 GMT
> Hi,
>
[quoted text clipped - 34 lines]
> questions
> if the description of this problem isn't satisfactory.

How did you manage to compile this unmanaged code that calls
InterlockedExchange64, this function is only available on 64bit OS (Vista,
W2K3 64bit) NOT on XP. 32 bit OS should use InterlockedExchange.

Willy.
Mikanu - 26 Sep 2005 23:08 GMT
Good, at least now we're getting somewhere... i thought that was a bit odd
but the thing is if I try using InterlockedExchange it doesn't compile, even
the IntelliSense won't pick it up!... I know it's there, but it won't
compile. Is there anything that I should do to insure that VC is not
targeting 64 bit OS.. or to force it to use the InterlockedExchange instead
or hte 64 one ?!

Thanks a lot,

Signature

Mikk,
mikkanu@community.nospam

"Jeffrey Tan[MSFT]" - 27 Sep 2005 09:27 GMT
Hi Mikk,

I am not sure why you believe your problem has something to do with 64bit
OS. Have you tried to create a VC.net Windows Forms application? Then, do
the following:

#include<windows.h>
private: System::Void Form1_Load(System::Object *  sender,
System::EventArgs *  e)
{
    long lv;
    ::InterlockedExchange(&lv, 4);
}
Can you do this successfully?

If you can not, I suggest you try another machine, then we can determine if
this issue is machine-specific.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Mikanu - 27 Sep 2005 21:00 GMT
So,
it seems I was able to somehow make a new win32 lib project and get it to
copile with the ::InterlockedExchange(), not he 64 version. But what is still
strange is that the intellisense will not pick-up the InterlockedExchange()
but it will InterlockedExchange64(). to me, that's still a little strange.
And also I'm concerned because I don't know exactly why it didn't work
before... and like everybody is saying... how in the world, I got it to
compile with the 64 version. That's still a mistery.

Signature

Mikk,
mikkanu@community.nospam

> Hi Mikk,
>
[quoted text clipped - 21 lines]
> Get Secure! - www.microsoft.com/security
> This posting is provided "as is" with no warranties and confers no rights.
"Jeffrey Tan[MSFT]" - 28 Sep 2005 03:35 GMT
Hi Mikk,

Thanks for your feedback.

Yes, it is somewhat strange. However, based on my knowledge this maybe a
IDE issue. The quickest way to workaround IDE related issue is creating a
new project and porting the old project into the new project.

If you want to troubleshoot out the root cause, I think contacting
Microsoft PSS should be a correct way.

Thanks

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Mikanu - 28 Sep 2005 04:54 GMT
Hi Jeff,

Switching to the non-64 versions seems to have fixed the problem.

I can now load the assembly in the Evaluate Assembly tool and it says
"Urestricted". I'm no longer getting that "Can't Load Assembly" error, so
it's on to trying it into the main project.

Thanks,

Signature

Mikk,
mikkanu@community.nospam

"Jeffrey Tan[MSFT]" - 28 Sep 2005 06:55 GMT
Cool, it seems that it is still the configuration issue.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Signature

Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Willy Denoyette [MVP] - 27 Sep 2005 11:32 GMT
> Good, at least now we're getting somewhere... i thought that was a bit odd
> but the thing is if I try using InterlockedExchange it doesn't compile,
[quoted text clipped - 6 lines]
>
> Thanks a lot,

VS2003 cannot target 64bit Windows OS, the InterlockedExchange64 and
InterlockedExchange are both declared in winbase.h, InterlockedExchange64
can only be found if you explicitely target X64 or IA64 in your project, so
I guess you have your project settings wrong, check the command line
arguments for both the compile and the link step.

Willy.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.