TypeInitializationException when trying WinResourceQuickStart project

Topics: Development Team Discussion, User Discussion
May 13, 2009 at 11:17 PM

I got the TypeInitializationException in in MessageOfTheDayForm.cs file:

 private ResourceManager messageResources = ResourceFactory.GetResourceManager();

 

I highly suspect it has something todo w/ the way I configure the resource provider in app.config. See my content below:

 

 

 

 

 

 

 

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

<

</font></font><font size="2" color="#0000ff">

 

</font>

resourceProviders><font size="2" color="#0000ff"><font size="2" color="#0000ff">

<

</font></font><font size="2" color="#0000ff">

 

</font>

add resourcePathName="C:\Projects\EntlibContrib\Samples\Resource\WinResourceQuickStart\Resources

"resourceBaseName="FormResources" type="EntLibContrib.Resource.Providers.XmlResourceProvider, EntLibContrib.Resource, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null"

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

 

</font></font>
<font size="2" color="#0000ff">

 

</font>

 

name="Xml Resource Provider" /><font size="2" color="#0000ff"><font size="2" color="#0000ff">

<

</font></font>
<font size="2" color="#0000ff">

 

</font>

add resourcePathName="C:\Projects\EntlibContrib\Samples\Resource\WinResourceQuickStart\Resources

"resourceBaseName="MessageResources" type="EntLibContrib.Resource.Providers.BinaryResourceProvider, EntLibContrib.Resource, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null"

<font size="2" color="#0000ff"><font size="2" color="#0000ff">

 

</font></font>
<font size="2" color="#0000ff">

 

</font>

 

name="Binary Resource Provider"/><font size="2" color="#0000ff"><font size="2" color="#0000ff">

</

</font></font>
<font size="2" color="#0000ff">

 

</font>

resourceProviders>

I'm pretty sure I'm getting the right location. Not sure whether the"\" and"/" in the filepath configuration matters.

May 13, 2009 at 11:18 PM

updated w/ cleaner config xml code:   

<resourceProviders>
      <add resourcePathName="C:\Projects\EntlibContrib\Samples\Resource\WinResourceQuickStart\Resources"
        resourceBaseName="FormResources" type="EntLibContrib.Resource.Providers.XmlResourceProvider, EntLibContrib.Resource, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null"
        name="Xml Resource Provider" />
      <add resourcePathName="C:\Projects\EntlibContrib\Samples\Resource\WinResourceQuickStart\Resources"
        resourceBaseName="MessageResources" type="EntLibContrib.Resource.Providers.BinaryResourceProvider, EntLibContrib.Resource, Version=3.1.0.0, Culture=neutral, PublicKeyToken=null"
        name="Binary Resource Provider" />
    </resourceProviders>

Coordinator
May 14, 2009 at 10:50 PM

Hi Tonyeka,

Your config looks OK to me so a couple of things to consider. With the release there is the source code download and there is also a binaries download.  If you compile the source you will get unsigned binaries.  The binaries given in the separate binaries download are all signed so they will not work with this config unless you replace the PublicKeyToken=null with the correct token =02ca582b160d0e09.

Another thing worth considering.  Even if you have unsigned binaries in your samples bin folder, if you have put the signed binaries into your GAC then these signed GAC binaries will be the ones loaded and will not work for the same reason as the above.

I hope this helps

Cheers...   Steve

May 15, 2009 at 3:52 AM
Thanks Steve,

I will wait till the v4.1 is released. Hopefully it will cleared up other issues too.

TW


From: [email removed]
To: [email removed]
Date: Thu, 14 May 2009 15:50:39 -0700
Subject: Re: TypeInitializationException when trying WinResourceQuickStart project [entlibcontrib:56236]

From: ewdev
Hi Tonyeka,
Your config looks OK to me so a couple of things to consider. With the release there is the source code download and there is also a binaries download. If you compile the source you will get unsigned binaries. The binaries given in the separate binaries download are all signed so they will not work with this config unless you replace the PublicKeyToken=null with the correct token =02ca582b160d0e09.
Another thing worth considering. Even if you have unsigned binaries in your samples bin folder, if you have put the signed binaries into your GAC then these signed GAC binaries will be the ones loaded and will not work for the same reason as the above.
I hope this helps
Cheers... Steve


Hotmail® goes with you. Get it on your BlackBerry or iPhone.
Coordinator
May 16, 2009 at 12:12 PM

Resource Application Block v4.1 is available from source code and can be found in the EntLibContrib41Src folder.

Cheers...   Steve