473,387 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

resources in vs.net

I've been coding a C# project in "pure code" and I would now want to import
it into VS.net. I have created a project and imported all sourcefiles and
it's compiling without problems, except for the resources. Before, I built
the program using a batchfile and linked the resources with the
"/resource:MainFrame.resX" option. Then I loaded them with this code:

Assembly myAssembly = Assembly.GetAssembly(this.GetType());
Stream resXStream =
myAssembly.GetManifestResourceStream("MainFrame.re sX");
ResXResourceSet resX = new ResXResourceSet(resXStream);

The problem is the way VS manages resources. It can't find MainFrame.resX
and i get an error because resXStream = null. I've tried to change the
"Build Action" -property of the files, but it doesn't seem to make any
difference. It's the same problem with images. Is there any way to change
the way the resources is included? I don't want to rewrite the whole program
because of incompability between VS and the compiler.
Nov 15 '05 #1
5 4690
I've added the files to the project and tried different settings for Build
Action. I won't be using the WinForm-designer since my forms are handmade. I
just want to edit my code in vs and use the build function.
This problem applies to all my images too, and I just want my resources to
be included the same way that the "/resource:image.png" option does.
Is there any way to send this option to the compiler manualy in VS?
Thanks for trying to help me!

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> skrev i
meddelandet news:OR**************@TK2MSFTNGP09.phx.gbl...
Marcus,
Did you include MainFrame.ResX in your project?

Did you set the Build Action (in the properties window) for the above file
to Embedded Resource?

Watch namespaces. Use Reflector to verify the names of the resources in the assembly.

Note: If you have a form names MainFrame, VS.NET will create a
MainFrame.Resx for you. Use Show All Files in solution explorer.

Hope this helps
Jay

"Marcus Ahlberg" <ca********@swipnet.se> wrote in message
news:O4*************@TK2MSFTNGP09.phx.gbl...
I've been coding a C# project in "pure code" and I would now want to

import
it into VS.net. I have created a project and imported all sourcefiles and it's compiling without problems, except for the resources. Before, I built the program using a batchfile and linked the resources with the
"/resource:MainFrame.resX" option. Then I loaded them with this code:

Assembly myAssembly = Assembly.GetAssembly(this.GetType());
Stream resXStream =
myAssembly.GetManifestResourceStream("MainFrame.re sX");
ResXResourceSet resX = new ResXResourceSet(resXStream);

The problem is the way VS manages resources. It can't find MainFrame.resX and i get an error because resXStream = null. I've tried to change the
"Build Action" -property of the files, but it doesn't seem to make any
difference. It's the same problem with images. Is there any way to change the way the resources is included? I don't want to rewrite the whole

program
because of incompability between VS and the compiler.


Nov 15 '05 #2
Marcus,
That's fine, you do not need to use the WinForm Designer with VS.NET.

My question still stands: Did you add the MainFrame.resx to your project,
and set the build action to Embedded Resource.

As it sounds like you want to embed the resource in the exactable, to do
this with VS.NET, you add the resx file to your project, and set the build
action to embedded resource. Did you do that?

If you have done the above, and it is still not working, I suspect the
namespace of your resource does not match the namespace you are trying to
use to retrieve it. You can use Reflector to verify the namespace. See
http://www.aisto.com/roeder/dotnet/ for Reflector.
Is there any way to send this option to the compiler manually in VS? Yes there is! ;-)

Build Action = Embedded Resource. Works for .resx files and any other file
type you give it.

Hope this helps
Jay

"Marcus Ahlberg" <ca********@swipnet.se> wrote in message
news:OP**************@TK2MSFTNGP09.phx.gbl... I've added the files to the project and tried different settings for Build
Action. I won't be using the WinForm-designer since my forms are handmade. I just want to edit my code in vs and use the build function.
This problem applies to all my images too, and I just want my resources to
be included the same way that the "/resource:image.png" option does.
Is there any way to send this option to the compiler manualy in VS?
Thanks for trying to help me!

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> skrev i
meddelandet news:OR**************@TK2MSFTNGP09.phx.gbl...
Marcus,
Did you include MainFrame.ResX in your project?

Did you set the Build Action (in the properties window) for the above file
to Embedded Resource?

Watch namespaces. Use Reflector to verify the names of the resources in

the
assembly.

Note: If you have a form names MainFrame, VS.NET will create a
MainFrame.Resx for you. Use Show All Files in solution explorer.

Hope this helps
Jay

"Marcus Ahlberg" <ca********@swipnet.se> wrote in message
news:O4*************@TK2MSFTNGP09.phx.gbl...
I've been coding a C# project in "pure code" and I would now want to

import
it into VS.net. I have created a project and imported all sourcefiles

and it's compiling without problems, except for the resources. Before, I built the program using a batchfile and linked the resources with the
"/resource:MainFrame.resX" option. Then I loaded them with this code:

Assembly myAssembly = Assembly.GetAssembly(this.GetType());
Stream resXStream =
myAssembly.GetManifestResourceStream("MainFrame.re sX");
ResXResourceSet resX = new ResXResourceSet(resXStream);

The problem is the way VS manages resources. It can't find MainFrame.resX and i get an error because resXStream = null. I've tried to change the
"Build Action" -property of the files, but it doesn't seem to make any
difference. It's the same problem with images. Is there any way to change the way the resources is included? I don't want to rewrite the whole

program
because of incompability between VS and the compiler.



Nov 15 '05 #3
Yes I set the Build action to Embeded Resource, but it is not exactly the
same thing.

For the images, it seems like they are included the same way, but they are
all put in a namespace like "Marcusoft.TextWrite.res.CommandIcons.bmp" but I
want them to exist outside the namespace like "CommandIcons.bmp". Do you
know how to specify witch namespace to put them in?

I called "myAssembly.GetManifestResourceNames()" and I found the name
"Marcusoft.TextWrite.res.MainFrame.resources", but it is not a valid resX
input. It seems like VS is doing something with the resX-files.

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> skrev i
meddelandet news:uB**************@TK2MSFTNGP12.phx.gbl...
Marcus,
That's fine, you do not need to use the WinForm Designer with VS.NET.

My question still stands: Did you add the MainFrame.resx to your project,
and set the build action to Embedded Resource.

As it sounds like you want to embed the resource in the exactable, to do
this with VS.NET, you add the resx file to your project, and set the build
action to embedded resource. Did you do that?

If you have done the above, and it is still not working, I suspect the
namespace of your resource does not match the namespace you are trying to
use to retrieve it. You can use Reflector to verify the namespace. See
http://www.aisto.com/roeder/dotnet/ for Reflector.
Is there any way to send this option to the compiler manually in VS? Yes there is! ;-)

Build Action = Embedded Resource. Works for .resx files and any other file
type you give it.

Hope this helps
Jay

"Marcus Ahlberg" <ca********@swipnet.se> wrote in message
news:OP**************@TK2MSFTNGP09.phx.gbl...
I've added the files to the project and tried different settings for Build
Action. I won't be using the WinForm-designer since my forms are handmade. I
just want to edit my code in vs and use the build function.
This problem applies to all my images too, and I just want my resources

to be included the same way that the "/resource:image.png" option does.
Is there any way to send this option to the compiler manualy in VS?
Thanks for trying to help me!

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> skrev i
meddelandet news:OR**************@TK2MSFTNGP09.phx.gbl...
Marcus,
Did you include MainFrame.ResX in your project?

Did you set the Build Action (in the properties window) for the above file to Embedded Resource?

Watch namespaces. Use Reflector to verify the names of the resources in the
assembly.

Note: If you have a form names MainFrame, VS.NET will create a
MainFrame.Resx for you. Use Show All Files in solution explorer.

Hope this helps
Jay

"Marcus Ahlberg" <ca********@swipnet.se> wrote in message
news:O4*************@TK2MSFTNGP09.phx.gbl...
> I've been coding a C# project in "pure code" and I would now want to
import
> it into VS.net. I have created a project and imported all
sourcefiles and
> it's compiling without problems, except for the resources. Before, I

built
> the program using a batchfile and linked the resources with the
> "/resource:MainFrame.resX" option. Then I loaded them with this

code: >
> Assembly myAssembly = Assembly.GetAssembly(this.GetType());
> Stream resXStream =
> myAssembly.GetManifestResourceStream("MainFrame.re sX");
> ResXResourceSet resX = new ResXResourceSet(resXStream);
>
> The problem is the way VS manages resources. It can't find

MainFrame.resX
> and i get an error because resXStream = null. I've tried to change the > "Build Action" -property of the files, but it doesn't seem to make any > difference. It's the same problem with images. Is there any way to

change
> the way the resources is included? I don't want to rewrite the whole
program
> because of incompability between VS and the compiler.
>
>



Nov 15 '05 #4
Marcus,
Yes I set the Build action to Embeded Resource, but it is not exactly the
same thing. For bitmaps, other than namespace how is it different? As your found out,
..resx files are actually compiled and embedded as .resources.
Do you know how to specify witch namespace to put them in? I do not know how to control the namespace that VS.NET uses when it includes
the resource. I wish I did.

The little bit of testing I have done with it, C# seems to behave better
about it, then VB.NET does. In that the namespaces that C# uses seem more
natural.
I called "myAssembly.GetManifestResourceNames()" and I found the name
"Marcusoft.TextWrite.res.MainFrame.resources", but it is not a valid resX
input. It seems like VS is doing something with the resX-files. VS.NET compiles your .resx files into .resource files, it then embeds the
..resource file into the assembly. You will need to change your code that
uses .resx to use .resource. The ResourceManager makes this rather easy.

http://msdn.microsoft.com/library/de...rcemanager.asp

Hope this helps
Jay

"Marcus Ahlberg" <ca********@swipnet.se> wrote in message
news:uX**************@TK2MSFTNGP11.phx.gbl... Yes I set the Build action to Embeded Resource, but it is not exactly the
same thing.

For the images, it seems like they are included the same way, but they are
all put in a namespace like "Marcusoft.TextWrite.res.CommandIcons.bmp" but I want them to exist outside the namespace like "CommandIcons.bmp". Do you
know how to specify witch namespace to put them in?

I called "myAssembly.GetManifestResourceNames()" and I found the name
"Marcusoft.TextWrite.res.MainFrame.resources", but it is not a valid resX
input. It seems like VS is doing something with the resX-files.

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> skrev i
meddelandet news:uB**************@TK2MSFTNGP12.phx.gbl...
Marcus,
That's fine, you do not need to use the WinForm Designer with VS.NET.

My question still stands: Did you add the MainFrame.resx to your project,
and set the build action to Embedded Resource.

As it sounds like you want to embed the resource in the exactable, to do
this with VS.NET, you add the resx file to your project, and set the build action to embedded resource. Did you do that?

If you have done the above, and it is still not working, I suspect the
namespace of your resource does not match the namespace you are trying to use to retrieve it. You can use Reflector to verify the namespace. See
http://www.aisto.com/roeder/dotnet/ for Reflector.
Is there any way to send this option to the compiler manually in VS? Yes there is! ;-)

Build Action = Embedded Resource. Works for .resx files and any other file type you give it.

Hope this helps
Jay

"Marcus Ahlberg" <ca********@swipnet.se> wrote in message
news:OP**************@TK2MSFTNGP09.phx.gbl...
I've added the files to the project and tried different settings for Build Action. I won't be using the WinForm-designer since my forms are handmade.
I
just want to edit my code in vs and use the build function.
This problem applies to all my images too, and I just want my resources to be included the same way that the "/resource:image.png" option does.
Is there any way to send this option to the compiler manualy in VS?
Thanks for trying to help me!

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> skrev i
meddelandet news:OR**************@TK2MSFTNGP09.phx.gbl...
> Marcus,
> Did you include MainFrame.ResX in your project?
>
> Did you set the Build Action (in the properties window) for the
above file
> to Embedded Resource?
>
> Watch namespaces. Use Reflector to verify the names of the resources

in the
> assembly.
>
> Note: If you have a form names MainFrame, VS.NET will create a
> MainFrame.Resx for you. Use Show All Files in solution explorer.
>
> Hope this helps
> Jay
>
> "Marcus Ahlberg" <ca********@swipnet.se> wrote in message
> news:O4*************@TK2MSFTNGP09.phx.gbl...
> > I've been coding a C# project in "pure code" and I would now want
to > import
> > it into VS.net. I have created a project and imported all

sourcefiles and
> > it's compiling without problems, except for the resources. Before, I built
> > the program using a batchfile and linked the resources with the
> > "/resource:MainFrame.resX" option. Then I loaded them with this code: > >
> > Assembly myAssembly = Assembly.GetAssembly(this.GetType());
> > Stream resXStream =
> > myAssembly.GetManifestResourceStream("MainFrame.re sX");
> > ResXResourceSet resX = new ResXResourceSet(resXStream);
> >
> > The problem is the way VS manages resources. It can't find
MainFrame.resX
> > and i get an error because resXStream = null. I've tried to change the > > "Build Action" -property of the files, but it doesn't seem to make any > > difference. It's the same problem with images. Is there any way to
change
> > the way the resources is included? I don't want to rewrite the whole > program
> > because of incompability between VS and the compiler.
> >
> >
>
>



Nov 15 '05 #5
It seems like the only way is to rewrite my code.
Thanks for your help.

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> skrev i
meddelandet news:#p**************@TK2MSFTNGP12.phx.gbl...
Marcus,
Yes I set the Build action to Embeded Resource, but it is not exactly the
same thing. For bitmaps, other than namespace how is it different? As your found out,
.resx files are actually compiled and embedded as .resources.
Do you know how to specify witch namespace to put them in?

I do not know how to control the namespace that VS.NET uses when it

includes the resource. I wish I did.

The little bit of testing I have done with it, C# seems to behave better
about it, then VB.NET does. In that the namespaces that C# uses seem more
natural.
I called "myAssembly.GetManifestResourceNames()" and I found the name
"Marcusoft.TextWrite.res.MainFrame.resources", but it is not a valid resX input. It seems like VS is doing something with the resX-files. VS.NET compiles your .resx files into .resource files, it then embeds the
.resource file into the assembly. You will need to change your code that
uses .resx to use .resource. The ResourceManager makes this rather easy.

http://msdn.microsoft.com/library/de...us/cptutorials
/html/resourcemanager.asp
Hope this helps
Jay

"Marcus Ahlberg" <ca********@swipnet.se> wrote in message
news:uX**************@TK2MSFTNGP11.phx.gbl...
Yes I set the Build action to Embeded Resource, but it is not exactly the same thing.

For the images, it seems like they are included the same way, but they are all put in a namespace like "Marcusoft.TextWrite.res.CommandIcons.bmp" but
I
want them to exist outside the namespace like "CommandIcons.bmp". Do you
know how to specify witch namespace to put them in?

I called "myAssembly.GetManifestResourceNames()" and I found the name
"Marcusoft.TextWrite.res.MainFrame.resources", but it is not a valid
resX input. It seems like VS is doing something with the resX-files.

"Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> skrev i
meddelandet news:uB**************@TK2MSFTNGP12.phx.gbl...
Marcus,
That's fine, you do not need to use the WinForm Designer with VS.NET.

My question still stands: Did you add the MainFrame.resx to your project, and set the build action to Embedded Resource.

As it sounds like you want to embed the resource in the exactable, to do this with VS.NET, you add the resx file to your project, and set the build action to embedded resource. Did you do that?

If you have done the above, and it is still not working, I suspect the
namespace of your resource does not match the namespace you are trying to use to retrieve it. You can use Reflector to verify the namespace. See
http://www.aisto.com/roeder/dotnet/ for Reflector.

> Is there any way to send this option to the compiler manually in VS?
Yes there is! ;-)

Build Action = Embedded Resource. Works for .resx files and any other file type you give it.

Hope this helps
Jay

"Marcus Ahlberg" <ca********@swipnet.se> wrote in message
news:OP**************@TK2MSFTNGP09.phx.gbl...
> I've added the files to the project and tried different settings for

Build
> Action. I won't be using the WinForm-designer since my forms are

handmade.
I
> just want to edit my code in vs and use the build function.
> This problem applies to all my images too, and I just want my resources
to
> be included the same way that the "/resource:image.png" option does.
> Is there any way to send this option to the compiler manualy in VS?
> Thanks for trying to help me!
>
> "Jay B. Harlow [MVP - Outlook]" <Ja********@email.msn.com> skrev i
> meddelandet news:OR**************@TK2MSFTNGP09.phx.gbl...
> > Marcus,
> > Did you include MainFrame.ResX in your project?
> >
> > Did you set the Build Action (in the properties window) for the

above file
> > to Embedded Resource?
> >
> > Watch namespaces. Use Reflector to verify the names of the resources in
> the
> > assembly.
> >
> > Note: If you have a form names MainFrame, VS.NET will create a
> > MainFrame.Resx for you. Use Show All Files in solution explorer.
> >
> > Hope this helps
> > Jay
> >
> > "Marcus Ahlberg" <ca********@swipnet.se> wrote in message
> > news:O4*************@TK2MSFTNGP09.phx.gbl...
> > > I've been coding a C# project in "pure code" and I would now
want to > > import
> > > it into VS.net. I have created a project and imported all sourcefiles
> and
> > > it's compiling without problems, except for the resources.
Before, I > built
> > > the program using a batchfile and linked the resources with the
> > > "/resource:MainFrame.resX" option. Then I loaded them with this

code:
> > >
> > > Assembly myAssembly = Assembly.GetAssembly(this.GetType());
> > > Stream resXStream =
> > > myAssembly.GetManifestResourceStream("MainFrame.re sX");
> > > ResXResourceSet resX = new ResXResourceSet(resXStream);
> > >
> > > The problem is the way VS manages resources. It can't find
> MainFrame.resX
> > > and i get an error because resXStream = null. I've tried to
change
the
> > > "Build Action" -property of the files, but it doesn't seem to
make any
> > > difference. It's the same problem with images. Is there any way

to > change
> > > the way the resources is included? I don't want to rewrite the

whole > > program
> > > because of incompability between VS and the compiler.
> > >
> > >
> >
> >
>
>



Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Derick Smith | last post by:
Hi! I am just starting to use .NET and need some help! If I create my own DLL for String resouces using this command: C:\WINNT\MICROS~1.NET\Framework\v1.1.4322\Al /t:lib...
3
by: Jesse | last post by:
Hi together, I've a problem with compiling an application with a build-Script and run it after. Several resource-files I compile with resgen.exe and put the files into a folders of the...
1
by: Stefan Turalski \(stic\) | last post by:
Hi, What I need to do is adding some support for resources files to my application. What I did is: MyAppMain <- startup project MyAppHelper <- project which has MyAppResourcesClass (al a...
4
by: Rachel Suddeth | last post by:
What is the difference between a managed/unmanaged resource, and how do you tell which is which? I'm trying to understand how to write some Dispose() methods, and we are supposed to put code that...
4
by: Jon Rista | last post by:
I have a project where I need to create a windows .exe by compiling code and linking in some resources. This program thats being generated is somewhat unconventional, and I'll explain how. I'm...
0
by: Johann Blake | last post by:
I'm having trouble grasping how ASP.NET correctly locates resources. There is plenty of documentation on this subject but some things are not clear at all. In my ASP.NET application, I have...
0
by: Derick Smith | last post by:
Hi! I am just starting to use .NET and need some help! If I create my own DLL for String resouces using this command: C:\WINNT\MICROS~1.NET\Framework\v1.1.4322\Al /t:lib...
0
by: Rob Dob | last post by:
Hi, I have a VS2003 C# asp.net project that has been converted into a VS2005 project. Everything seemed to work well until I make a modification to anything within the Component Designer...
1
by: spencermiles | last post by:
Hello, I'm working on a large solution, comprised on numerous Projects, and I would like to have one central projects that contains a set of global RESX Resources. It doesn't make sense to have...
0
by: shamirza | last post by:
· When was .NET announced? Bill Gates delivered a keynote at Forum 2000, held June 22, 2000, outlining the .NET 'vision'. The July 2000 PDC had a number of sessions on .NET technology, and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.