[mapguide-users] Application compatibility b/w MGE2009 and MGOS 2.0.2

Kenneth Skovhede, GEOGRAF A/S ks at geograf.dk
Sat Nov 29 08:45:30 EST 2008


The "Invalid Stream Header" is a sort-of catch-all exception that happens
when the MapGuide service tries to de-serialize an object, and finds 
something it does not expect.
The usual cause of this is the other (unmanaged) binaries.

The MapGuideDotNet.dll file is a thin wrapper that just calls the 
unmanaged dll's.

So you can bind .Net to either version of the managed dll, but you MUST 
have the correct
unmanaged dll's in the bin folder.

Alternatively, you can fix the binding through the Web.config file:
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="MapGuideDotNetApi" 
publicKeyToken="f526c48929fda856" />
        <bindingRedirect oldVersion="2.0.0.2308" newVersion="1.2.0.4103" />
      </dependentAssembly>
    </assemblyBinding>   
  </runtime>
</configuration>

Replace the publicKeyToken and version as you please.

There was a slight change with MgDisposable/MgGuardedDisposable some 
time ago.
If you run into that, you have to use the re-bind option described above.

Regards, Kenneth Skovhede, GEOGRAF A/S



MacNair skrev:
> We have a Mapguide application developed using MGE 2009’s library.  This
> application does most of its work by calling methods from another DLL called
> “MGEUtils.DLL”. This DLL references “MapGuideDotNet.DLL”.
>
> The application works fine on the development machine where MGE is
> installed. But on the deployment machine where MapGuide Open Source (MGOS 
> 2.0.2.3011) is installed we are getting a few errors. 
>
> Should we recompile the class library “MGEUtils” referencing MGOS’s
> MapGuideDotNet.DLL?
>
> The calls made to the methods in MGEUtils to initialize the application are
> throwing a few errors as given under. Note: The function definitions for
> these methods are given in Appendix below:
>
> // Initialize the webtier      
> string sErrMsg = "";
> mgeUtils.InitializeWebTier(configPath, sErrMsg);    
>
> // Validate the user login and create a session  
> mgeUtils.InitialiseSession("Anonymous", "", ref sessionId, ref sErrMsg);
>
> Note:  The function definitions for the above calls within MGEUtils are
> given at the end of this document.
>
> Errors encounterd are…
>
> CASE I: Placing MGE’s MapGuideDotNet.dll  along with “MGEUtils.DLL”  in the
> application’s bin directory.
> Error @ LINE: mgeUtils.InitialiseSession("Anonymous", "", ref sessionId, ref
> sErrMsg);
> Error details: OSGeo.MapGuide.MgInvalidStreamHeaderException: Invalid stream
> header exception
>
> CASE II: Placing MGOS ’s MapGuideDotNet.dll  along with “MGEUtils.DLL”  in
> the application’s bin directory.
> Error @ LINE: mgeUtils.InitializeWebTier(configPath, sErrMsg);
> Error details: Could not load file or assembly 'MapGuideDotNetApi,
> Version=2.0.0.3202, Culture=neutral, PublicKeyToken=6416a18f8953383b' or one
> of its dependencies. The located assembly's manifest definition does not
> match the assembly reference. (Exception from HRESULT: 0x80131040) 
>
> Any help on this? Sorry for the lengthy mail. Thanks!
>
> Function defintions
>
> public bool InitializeWebTier(string configPath, string csErrMsg)
> {
>    try
>    {
>      // Check if the webConfig file exists
>      if (!File.Exists(configPath)) { return false; }
>      
>      MapGuideApi.MgInitializeWebTier(configPath);
> 	return true;
>     }
>     catch (MgConnectionFailedException mge)
>     {
> 	csErrMsg = mge.GetMessage();
> 	return false;
>     }
> }
> public bool InitialiseSession(string userName, string userPwd, ref string
> sessionId, ref string csErrMsg)
> {
>   try
>   {
>    // Validate user login
>    MgUserInformation userInfo = new MgUserInformation(userName, userPwd);
>    MgSite site = new MgSite();
>    site.Open(userInfo);
>
>    // Create a session
>    sessionId = site.CreateSession();
>   }
>   catch (MgConnectionFailedException mge)
>   {
>    csErrMsg = mge.GetMessage();
>    return false;
>   }
>   
>   return true;
> }
>
>
>
>   


More information about the mapguide-users mailing list