SharpDevelop Community

Get your problems solved!
Welcome to SharpDevelop Community Sign in | Join | Help
in Search

Visual Studio 2008 + load resources

Last post 06-11-2008 8:54 PM by mikehachen. 5 replies.
Page 1 of 1 (6 items)
Sort Posts: Previous Next
  • 03-10-2008 10:08 PM

    Visual Studio 2008 + load resources

     Hello: (My English is not so good, so i am sorry at first) I read Building Applications with the SharpDevelop Core on Codeproject to understand How ICSharpCode.Core workin. Everythink works fine with Visual Studio 2005. I wrote my own program on ICSharpCode.Core.

     My problem is: When am i began use VS 2008 Embeded resources as BitmapResources dosn't work. I use:

                Assembly exe = typeof(Start).Assembly;

                ResourceService.RegisterNeutralStrings(new ResourceManager("Startup.StringResources", exe));
                ResourceService.RegisterNeutralImages(new ResourceManager("Startup.ImageResources", exe));

     

    Is it same as in ICSharpCode.Core.Demo.

    When i compile my program in in VS 2008 and want use resources for example:

    <MenuItem id = "RefreshGraph"
                    label = "${res:Editor.Refresh}"
                    icon = "Icons.Refresh16"
                    class = "Editor.RefreshGraph"/>

    Icons.Refresh16 is in  ImageResources.resources, but ICSharpCode make Exception that Icons.Refresh16 dosn't exist.

    So i think that problem is in me so i try compile  ICSharpCode.Core.Demo with VS 2008.Here is problem, too.

    So i try compile #develop 3.0 in VS2008 and here are the resources loaded.

    Can you help me please?

    PS: Resources are embeded in exe file. You are doing GREAT JOB, THANK YOU

              

     

  • 03-15-2008 3:52 PM In reply to

    Re: Visual Studio 2008 + load resources

    When you open ICSharpCode.Core.Demo in VS 2008 it converts the project so it targets .NET 3.5. This then uses the new C# compiler which embed the .resources file differently. They lose the .resources part of the resource name.

    Embedded as:

    Startup.ImageResources
    Startup.BitmapResources

    Should be:

    Startup.ImageResources.resources
    Startup.BitmapResources.resources


    When you run the ICSharpCode.Core.Demo the ResourceManager cannot find them since they are missing the file extension.

    To fix the problem use ResGen.exe (part of the .NET SDK) and convert the .resources to .resx then remove the .resources from the project and add the .resx to the project. Then ICSharpCode.Core.Demo should work.

  • 03-22-2008 12:21 PM In reply to

    Re: Visual Studio 2008 + load resources

    Another way to fix this is to use the <LogicalName> element as shown below.

       <EmbeddedResource Include="Resources\StringResources.resources">

          <LogicalName>Resources.StringResources.resources</LogicalName>
       </EmbeddedResource>

       <EmbeddedResource Include="Resources\BitmapResources.resources">
          <LogicalName>Resources.BitmapResources.resources</LogicalName>
       </EmbeddedResource>
  • 06-11-2008 1:20 PM In reply to

    Re: Visual Studio 2008 + load resources

    Hi

    I also have some troubles getting resource files working. In my project I have a resouce file called ImageResources.resx with build action set to Embedded Resource. In the file Startup.cs I added the line:

    ResourceService.RegisterNeutralImages(new ResourceManager("ImageResources", exe));

     In the Base.addin I have the following lines:

    <Path name = "/MainForm/Toolbar">
    <
    ToolbarItem id = "Open"
    tooltip = "Open existing file"
    icon ="Icons_Open"
    class = "Arcos.ERP.Base.MainMenu.OpenCompanyCommand"/>
    </Path>

    When I try to start my project I get an error on the line where I want to build the toolbar:

    toolbar = ToolbarService.CreateToolStrip(this, "/MainForm/Toolbar");

    Error: Resource not found : Icons_Open

    The icon "Icons_Open" does exists in the resource file. So where is the problem, what am I doing wrong? I'm using VS 2008 and the .NET Framework 3.5.

    Thank you for your help!

    Mike

  • 06-11-2008 5:45 PM In reply to

    Re: Visual Studio 2008 + load resources

    Add the root namespace of your project to the name of the resource passed to the ResourceManager constructor.

    ResourceService.RegisterNeutralImages(new ResourceManager("ASSEMBLY_ROOT_NAMESPACE.ImageResources", exe));

    The root namespace is typically the same as the name of the project. You can see the root namespace in the Project options in the Application tab. 

  • 06-11-2008 8:54 PM In reply to

    Re: Visual Studio 2008 + load resources

    Hey MattWard

     

    Great, it works!

    Thank you for your help, Mike

Page 1 of 1 (6 items)
Powered by Community Server (Commercial Edition), by Telligent Systems
Don't contact us via this (fleischfalle@alphasierrapapa.com) email address.