none
How to load XSL from Resource(Resx) files in Class library?

    Question

  • Hi,

    Iam developing a class library. I am using one xsl (style sheet) in my class library project. In order to use that xsl iam giving path like "C:\kk\temp\Excel.xsl".   iam going to deliver this XSL to some other people. As the path is my machine specific, that resource will not be found at that location in others machine. So i try to use Resource files (resx)...iam unable to use that properly and make my DLL independent..

     

    Can anyone please explain me the complete steps for how to use resources(Resx files) for XSL so that i can make my XSL machine independent..??

     

    Wednesday, January 28, 2009 4:20 PM

Answers

  • An XSL file is simply a text file. Do the following:

    1. Double click the properties folder.
    2. In the resulting window, click the "Resources" tab.
    3. If nothing shows up but a gray screen and a blue link, click the blue link.
    4. Click the down arrow next to "Add Resource" at the top of the page. 
    5. Either select an existing file to load the existing xsl, or add a new text file, and copy the contents of your XSL into the text file.
    6. A folder will show up in your solution called "Resources".  Expand it.
    7. Right click on the file that you just added to the Resources folder, and click "Properties".
    8. In the properties window, change "Build Action" to "Embedded Resource".

    Now, in your code, you will retrieve this file as a string.  You will call "<AssemblyName>.Properties.Resources.<NameOfYourFile>". 


    David Morton - http://blog.davemorton.net/
    Wednesday, January 28, 2009 4:35 PM

All replies

  • An XSL file is simply a text file. Do the following:

    1. Double click the properties folder.
    2. In the resulting window, click the "Resources" tab.
    3. If nothing shows up but a gray screen and a blue link, click the blue link.
    4. Click the down arrow next to "Add Resource" at the top of the page. 
    5. Either select an existing file to load the existing xsl, or add a new text file, and copy the contents of your XSL into the text file.
    6. A folder will show up in your solution called "Resources".  Expand it.
    7. Right click on the file that you just added to the Resources folder, and click "Properties".
    8. In the properties window, change "Build Action" to "Embedded Resource".

    Now, in your code, you will retrieve this file as a string.  You will call "<AssemblyName>.Properties.Resources.<NameOfYourFile>". 


    David Morton - http://blog.davemorton.net/
    Wednesday, January 28, 2009 4:35 PM
  • Hi,

    Thanks for your reply.

    While using this way iam getting the error messsage.

    "XX.XX.XX.resources" was correctly embedded or linked into assembly "ExcelEncoderComp" at compile time, or that all the satellite assemblies required are loadable and fully signed.

    Please tell me how to overcome this error.

    Thursday, January 29, 2009 6:23 AM
  • Right click on Resources.resx (located in the Properties folder of your project).  Click on properties, what is entered under the "Build Action"?  It should be "Embedded Resource". 

    Also, ensure that Build Action for the specific file you're trying to access, which should be located in the Resources folder in your project is also listed with a Build Action of Embedded Resource.


    David Morton - http://blog.davemorton.net/
    Thursday, January 29, 2009 2:10 PM
  • I have solved the problem David.....I took other approach to resolve that error.....thank you very much
    Friday, January 30, 2009 11:16 AM
  •  
    mercedes_Kranthi said:

    I have solved the problem David.....I took other approach to resolve that error.....thank you very much

    Would you mind sharing what that other approach was?


    David Morton - http://blog.davemorton.net/
    Friday, January 30, 2009 3:13 PM