AssemblyResource not found

G

Guest

I have an embedded js resource in my Assembly asp.net 2.0

In the immediate Window I do:

((System.Web.UI.WebResourceAttribute)Attribute.GetCustomAttributes(Asm)[7])
{System.Web.UI.WebResourceAttribute}
base {System.Attribute}: {System.Web.UI.WebResourceAttribute}
ContentType: "application/x-javascript"
PerformSubstitution: false
WebResource: "Util.Ctrl.GridView.GridViewCheckBox.js"

and

Asm.GetManifestResourceInfo("Util.Ctrl.GridView.GridViewCheckBox.js")
null

Shouldn't I be getting something other than null???


my AssemblyInfo.cs contains:
[assembly: WebResource("Util.Ctrl.GridView.transparent.gif", "img/gif")]
[assembly: WebResource("Util.Ctrl.GridView.GridViewCheckBox.js",
"application/x-javascript")]


Asm.GetManifestResourceInfo("Util.Ctrl.GridView.transparent.gif")
{System.Reflection.ManifestResourceInfo}
FileName: null
ReferencedAssembly: null
ResourceLocation: Embedded | ContainedInManifestFile


The gif and the js files are in the same directory!
 
W

Walter Wang [MSFT]

Hi Chuck,

I'm not sure, would you please check if the build action of the .js file is
also set to "Embedded resource" as the .gif file? Please note, the naming
of the webresource should be composed of three parts: default namespace +
subdirectory path + file name.

For example, if your assembly has default namespace "ClassLibrary1", and
the GridViewCheckBox.js is located at a subdirectory "test", the web
resource name should be "ClassLibrary1.test.GridViewCheckBox.js".


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

Walter,
I did mess up and forgot to put the js file as an embedded resource.
However,

If I have the file in project directory at:


Util\Ctrl\GridView\GridViewCheckBox.js
and the assembly as
[assembly: WebResource("Util.Ctrl.GridView.GridViewCheckBox.js",
"application/x-javascript")]

everything works fine.

However if I move the file to:
Util\Ctrl\GridView\checkBox\GridViewCheckBox.js
and the assembly as:
[assembly: WebResource("Util.Ctrl.GridView.checkBox.GridViewCheckBox.js",
"application/x-javascript")]

it doesn't find it.

The project namespace is Util
The control which loads the embedded resource is in namespace
Util.Ctrl
 
W

Walter Wang [MSFT]

Hi Chuck,

Is the root/default namespace "Util.Ctrl"? and the directory in the project
starts with "GridView\checkbox\GridViewCheckBox.js"?

It's strange that it cannot find the resource. Can you send me a
reproducible project for further troubleshooting? Thanks.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
W

Walter Wang [MSFT]

Hi Chuck,

Thanks for the code.

I've done some test using your code:

1) Move GridViewCheckBox.js into its subfolder checkBox
2) Modify AssemblyInfo.cs to use:

[assembly: WebResource("Util.Ctrl.GridView.checkBox.GridViewCheckBox.js",
"application/x-javascript")]

3) Modify GridView_Ex.CheckBox.js:

private const string CheckBoxJsResourceLocation =
"Util.Ctrl.GridView.checkBox.GridViewCheckBox.js";

4) After I rebuilding the Ctrl.dll, I used a console program to test it and
it works correctly.

I suggest you rebuilding your project, of even re-add the reference if
necessary.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Guest

thanks,
I had to go into the test project, remove the reference to the util class
and then add it back before it would work. Just deleting the dll didnt work.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top