Quantcast
Channel: West Wind Message Board Messages
Viewing all articles
Browse latest Browse all 10393

Re: Enabling DbDesignTimeResourceProviderFactory

$
0
0
Re: Enabling DbDesignTimeResourceProviderFactory
West Wind Web Toolkit for ASP.NET
Re: Enabling DbDesignTimeResourceProviderFactory
02/14/2012
12:38:39 PM
3FL0R3PO2 Show this entire thread in new window
Gratar Image based on email address
From:
To:
Attachments:
None
Yes, I verified that.

After somemore spelunking, it seems the custom config section handler (DbResourceProviderSection) isn't being called or properly instantiated when web.config is parsed.
This line works:

var TSection = webApp.OpenWebConfiguration(true).GetSection("DbResourceProvider");

But then the next line returns null:

var Section = TSection as DbResourceProviderSection;


Make sure the resource provider is working first. Visual Studio will use the provider you define in the Globalization section and the design time attribute is what it looks for.

It's crucial that the provider works though (ie. the connection string is set and the database is set up). You should be able to test that the provider works by configuring the provider and running your app and check for the value of some resources.

+++ Rick ---


Can't seem to enable the feature which writes local resources to the DB when the Visual Studio command: "Generate Local Resource" is run, which would be enormously helpful for our project.

I have been able to get DbResourceProvider working.

It seems that the statement:

[DesignTimeResourceProviderFactoryAttribute(typeof(DbDesignTimeResourceProviderFactory))]

should be all that's required for Studio to find the factory.

When I invoke Generate Local Resource on simple test page with a single test string (Label.Text), nothing happens. The edit symbol flashes on the test page filename and then dissapears. There's no resx entry or db entry and there's no meta:resourcekey added in the webform.

I realize design time code is tough to debug, since you need a 2nd instance of Studio to debug the instance that invokes the design time assembly. I don't think the design factory is being invoked at all, since log4net trace statements aren't even called in the ctor.

Am I missing something obvious?

FYI: Visual Studio 2010 Pro, .NET 4.0, Windows7

<UPDATE> Clue from Studio Output window:


Start creating resource content and adding 'meta' attributes to server controls and directives.
Inheritance security rules violated by type: 'Westwind.Globalization.DbDesignTimeResourceProviderFactory'. Derived types must either match the security accessibility of the base type or be less accessible.
Finished creating resource content and adding 'meta' attributes.

Microsoft blog suggests:
Can you try setting the following assembly level attribute to force .NET 2.0 security rules.
[assembly: System.Security.SecurityRules(System.Security.SecurityRuleSet.Level1)]

Now, when I run Generate Local Resources I get:

Start creating resource content and adding 'meta' attributes to server controls and directives.
Object reference not set to an instance of an object.
Finished creating resource content and adding 'meta' attributes.


Viewing all articles
Browse latest Browse all 10393

Trending Articles