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 / January 2006

Tip: Looking for answers? Try searching our database.

TypeLoadException when v1.1 control is hosted by IE on v2.0 client

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
nkuslab - 18 Jan 2006 00:46 GMT
We have a strong-named and obfuscated .Net v1.1 Forms exe that can run as a
stand-alone app or have its main panel control hosted by IE using an
<object> tag and AllowPartiallyTrustedCallers.  While recently testing it on
a PC with CLR v2.0 installed, it works fine in stand-alone mode running
under both v1.1 and v2.0 (specified by the app config), however, it fails
with the following exception when hosted by IE:

Zone: 1

System.Reflection.TargetInvocationException: Exception has been thrown by
the target of an invocation. ---> System.TypeLoadException: Could not load
type 'System.Int32' from assembly '**********, Version=*.*.*.*,
Culture=neutral, PublicKeyToken=****************' due to value type
mismatch.
  at *********Panel..ctor()
  --- End of inner exception stack trace ---
  at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean
publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandle&
ctor, Boolean& bNeedSecurityCheck)
  at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean
fillCache)
  at System.RuntimeType.CreateInstanceImpl(Boolean publicOnly, Boolean
skipVisibilityChecks, Boolean fillCache)
  at System.Activator.CreateInstance(Type type, Boolean nonPublic)
  at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder
binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
  at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr,
Binder binder, Object[] args, CultureInfo culture, Object[]
activationAttributes)
  at System.Activator.CreateComInstanceFrom(String assemblyName, String
typeName, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm)
  at System.AppDomain.CreateComInstanceFrom(String assemblyFile, String
typeName, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm)
  at System.AppDomain.CreateComInstanceFrom(String assemblyFile, String
typeName, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm)
  at Microsoft.IE.SecureFactory.CreateInstanceWithSecurity(Int32 dwFlag,
Int32 dwZone, String pURL, String uniqueIdString, String link, String
licenses)

First, we cannot figure out why the CLR would try to load type System.Int32
from our assembly and second, we do not know how the unmanaged IExplore.exe
decides which CLR version to use when hosting a control loaded via the
<object> tag.  Placing an IExplore.exe.config file (with requiredRuntime
specified) into the folder with IExplore.exe on the client PC does the trick
but is not a viable option unless the customer agrees to this restriction
for all IE-hosted .Net controls.  Placing an IExplore.exe.config on the
server does not work because the file is not examined by the client until
after the CLR version decision is made (and even if it did work it would
make the CLR version server-global instead of client-global).  We realize
that unification generally precludes the hosted control from dictating the
CLR version to the host process but it seems that that option is needed on a
per-control basis for a generic host such as IE.  At this point, if the CLR
can't figure out that System.Int32 is in Mscorlib and we can't dictate which
CLR version IE should use when hosting our control (without dictating which
CLR version IE should use when hosting every other .Net control the customer
uses) then we will be forced to rebuild the app for v2.0 and hope that it
still works on PCs that only have v1.1 installed.

Suggestions, anyone?
"Jeffrey Tan[MSFT]" - 18 Jan 2006 06:54 GMT
Hi nkuslab,

Thanks for your post.

For this issue, I found a similiar issue in our internal database. That
issue is also caused by obfuscator. I am not sure if these 2 issues are the
same. Currently, I suggest you do not use obfuscator for the .Net1.1
application, then host it in IE, does the problem go away?

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.

nkuslab - 20 Jan 2006 20:29 GMT
Thanks Jeffery for your suggestion, updating the obfuscator solved the
problem.
"Jeffrey Tan[MSFT]" - 23 Jan 2006 01:32 GMT
Cool, it seems your issue is related with the known issue I found :-)

If you need further help, please feel free to post, 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.


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.