Tuesday, March 13, 2012

So new! What the Heck is PInvoke?

I'm sure my problem is stemming from the fact that I am writing my code on my home machine (with no access to the DB) and emailing it to the server offsite that doesn't have Visual Studio installed on it.
My version here at home is the 1.1 I think and the server has both versions of the framework installed.

Here's the error I'm getting when trying to run...

Invalid PInvoke metadata format.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.TypeLoadException: Invalid PInvoke metadata format.

Source Error:

Line 76: Dim rs As SqlDataReader
Line 77:
Line 78: objconn.Open()
Line 79:
Line 80: sSQL = "Select distinct ltrim(street_name) as sn from assess where street_name is not null order by ltrim(street_name)"

Source File: C:\Inetpub\wwwroot\MiamiLakesWeb\GarageSale.aspx.vb Line: 78

Stack Trace:

[TypeLoadException: Invalid PInvoke metadata format.]
System.Data.SqlClient.ConnectionPool.GetConnection(Boolean& isInTransaction) +483
System.Data.SqlClient.SqlConnectionPoolManager.GetPooledConnection(SqlConnectionString options, Boolean& isInTransaction) +370
System.Data.SqlClient.SqlConnection.Open() +383
MiamiLakesWeb.GarageSale.PopulateCombos() in C:\Inetpub\wwwroot\MiamiLakesWeb\GarageSale.aspx.vb:78
MiamiLakesWeb.GarageSale.Page_Load(Object sender, EventArgs e) in C:\Inetpub\wwwroot\MiamiLakesWeb\GarageSale.aspx.vb:69
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +29
System.Web.UI.Page.ProcessRequestMain() +707

------------------------
Version Information: Microsoft .NET Framework Version:1.0.3705.288; ASP.NET Version:1.0.3705.288

What is PInvoke? And why doesn't it want to be valid??

Thanks for any help!OK, so in the last few minutes I've found out more, hearing that this maybe a conflict between versions? I read somewhere to rename the 1.0 folder in the framework to kind of force the 1.1 to be used but unfortunately, I can't, access denied.

Are there other ways around this or should I call those network guys in to fix it?
Your probably right on the Framework version mismatch. If you look at the last line of the error message you posted "Version Information: Microsoft .NET Framework Version:1.0.3705.288; ASP.NET Version:1.0.3705.288" is for version 1.0 of the .NET Framework. If you compiled in 1.1 (Version 1.1.4322) then you are probably going to get all kinds of weird errors)
And...
(should've waited to post until I got all this info, huh??)

I've added the lines...

<startup
<requiredRuntime imageVersion="v1.0.3705" version="v1.0.3705" /
<supportedRuntime version="v1.1.4322" /
<supportedRuntime version="v1.0.3705" /
</startup
into my web.config and still nothing.
Yeah, looks like a version mismatch issue. If you don't need to support both then remove 1.0 or modify the config to redirect to 1.1.
OK, this maybe a stupid question but...

In which config file?

I put that code in my web.config file, then I also tried it in a few of the many framework config files. And none of it works.

Everything I've read here and thru my searches says to put it in the applications exe.config file. But I don't have one. This is driving me nuts!

Thank you for all your help!!
machine.config
Thanks SOOO Much!!

I'm sure you'll hear a lot more from me. :-)

0 comments:

Post a Comment