views:

345

answers:

2

I am trying to reference a js file in a class in an ASP.NET and I receive this error:

Assembly 'XXX' contains a Web resource with name 'XXX' but does not contain an embedded resource with name 'XXX'

Searching the web tell me I must have a Path referencing problem, but I can't figure what is it.

Here is the hierarchy

<Root>
   <App_Code>
      <Application>
          <MyClass.cs NameSpace="None" />
      </Application>
   </App_Code>
   <JS>
      <MyJSFile.js NameSpace="MyControls" Name="MyJSFile">
   </JS>
</Root>

So in MyClass.cs I have :

[assembly: WebResource("MyControls.JS.MyJSFile.js", "text/javascript")]

[ClientScriptResource("MyControls.JS.MyJSFile", "MyControls.JS.MyJSFile.js")]
public class MyClass : ExtenderControlBase
{}

So I guess there is something I didn't get with the referencing : (RootNampeSpace).(Path).(FileName).(Extension)

My project is a ASP.NET WEB Site so I don't have properties for Build Action to set at Embedded Resources.

Also in the folder App_Code I get an error if I put my JS file saying that the language is not the same as other file in App_Code.

A: 

You would think this is possible, but honestly I can't find how. I may be just missing something really simple...

You always have one other option, which is to create a separate Class Library project, embed your resources there, and reference it from your web site project.

Rex M
Yeah you maybe right. I was trying to avoid creating a new dll for project
lucian.jp
A: 

My project is a ASP.NET WEB Site so I don't have properties for Build Action to set at Embedded Resources.

I think that's your problem, that you can't really embed the resource, since there's no build step. What happens if you leave out the assembly attribute?

Dave Van den Eynde