none
Where did the Properties.Resources go?

    Question

  • Hi i have developed at UML modeling program i my sparetime. I'm curently moving all shapes to individual .dlls. (i.e. StateDiagram.dll, ClassDiagram.dll etc.)

    I want to store several icons in my .dll file. So i have added the resource.resx file to my Properties folder and added the icons. No prop.

    Now i want to access the resources. Normally i just go Properties.Resources.ResourceName, but the Properties namespace isent there.

    Any idea of what im missing here?

     

    Thanks in advance

    Esben Rasmussen, student at Engineerig College of Aarhus, Denmark

    Thursday, January 04, 2007 1:34 PM

Answers

  •  giflen wrote:

    Actually not. I want to access the resources form my dll project. (the rescources.resx is in the same project)

    public Image Icon

    {

    get { return Properties.Resources.image; }

    }

    - How you have added your resource in your dll project?
    If you have added a Resources.resx file and added your image to this file then the resource must be available using "Properties.Resources.image" and the property you wrote above must work. I have tested it and its working fine.

    In DLL project, you just need to confirm that Resources.Designer.cs has the same name space which is in your dll component class. Lets say if you have namespace "MyPrjName" in component class which is defalut the project name then your Resources.Designer.cs will have "MyPrjName.Properties" and if so then it will show it in intellisense. Its working fine with me.

    So if you are using the resources in DLL project the same way how i have described then please check the namespaces etc else tell us that how you have added resources in your dll project..

    HTH,

    Friday, January 05, 2007 8:21 AM

All replies

  • Hi,

    First thing i want to say is, the Resources you are accessing using "Properties.Resources.<ResourceName>" is for LOCAL project level only. If you have seen Resources.Designer.cs, Resources class generated is internal so you cant access out side of this project.

    So the solution could be,

    I am assuming that you want to access the image etc added in dll as resources from your main application,

    One solution I have for your problem,

    Steps:
    IN DLL
    1. As you may have done this, add Resources.resx and add the image etc you want in it.
    2. The Resources folder will be created in that dll where the image etc will be placed
    3. Select that image you added, select Properties, select "Embedded Resource" as Build Action
    4. Compile that dll

    In your main application:
    1. Add reference of above dll in this project
    2. wherever you want to use the resource from that dll, just wrote the code something like below,
    [I have added a picture box in my main application form and add image from another dll resource]
    The following code in Form Load method of my tester application works fine.
    Please fill up appropriate values where i put "<...>"

    Assembly asm = Assembly.Load("<Your Assembly Name - You can load the assembly using various methods>");

    string rsname = "<Your DLL Namespace Name from where you access resource>.Resources.<ImageName>.<Image extension>";

    Stream s = asm.GetManifestResourceStream(rsname);

    PictureBox p = new PictureBox();

    p.Image = Image.FromStream(s);

    this.Controls.Add(p);

    If this doesnt answer your question then please inform me the exact stuff you need, so I can answer that way,

     

    HTH,

    Thursday, January 04, 2007 5:29 PM
  • Actually not. I want to access the resources form my dll project. (the rescources.resx is in the same project)

    Reason: In my komponentclass i have at function that returns the image (resource). So all i have to do in the dll project is to access the image resource and return it.

    As i wrote, it shuld be pretty simple by:

    public Image Icon

    {

    get { return Properties.Resources.image; }

    }

     

    But my problem is that the Properties namespace is not in the intellisense. Its gone in the dll project. I must have forgotten some using or something.

    I have the same using in my dll project as i have in my Main program, and in my main program the Properties is in the intellisense.

     

    Hope it helps.

     

    Esben

    Thursday, January 04, 2007 6:15 PM
  •  giflen wrote:

    Actually not. I want to access the resources form my dll project. (the rescources.resx is in the same project)

    public Image Icon

    {

    get { return Properties.Resources.image; }

    }

    - How you have added your resource in your dll project?
    If you have added a Resources.resx file and added your image to this file then the resource must be available using "Properties.Resources.image" and the property you wrote above must work. I have tested it and its working fine.

    In DLL project, you just need to confirm that Resources.Designer.cs has the same name space which is in your dll component class. Lets say if you have namespace "MyPrjName" in component class which is defalut the project name then your Resources.Designer.cs will have "MyPrjName.Properties" and if so then it will show it in intellisense. Its working fine with me.

    So if you are using the resources in DLL project the same way how i have described then please check the namespaces etc else tell us that how you have added resources in your dll project..

    HTH,

    Friday, January 05, 2007 8:21 AM
  • the namespace was the problem. that fixed it. thanks a lot.

     

    Friday, January 05, 2007 12:24 PM
  • Hi,

    Please mark best and acceptable replie(s) as the ANSWER(S)

    Thanks,

    Friday, January 05, 2007 6:31 PM
  • Done. Again thanks.

    Have a great new yeat.

    Friday, January 05, 2007 8:46 PM