Hello,
I'm using Visual C# 2005 Express.
if I create a new "applicatio n windows" project and run it (F5), it works
well. (an empty window is launched..)
as soon as I set the build action to embedded resource, I can't run it
anymore because I got an error on
'WindowsApplica tion1.Form1.Dis pose(bool)'..
I find several examples online about embedded resource, but nothing that
give me an explanation on what I should do about that.
I'm beginning with C#, so I surely missed something, but I already search
for a moment without finding a solution, so if someone could help me a
little, it would be nice.
thanks.
Fred 8 2457
*what* are you setting as "embedded resource"? Form1.cs? What are you
trying to do? Basically, don't change this. You /do/ want to compile
this file, so leave it as "Compile" Embedded resource means that the
file is dumped (verbatim) into the assembly as a resource, useful for
including support files (xml, graphics, etc) with the app without
needing to deploy these files separately. But this is not how you
treat code, unless you genuinely intend to bundle the source file with
the app (instead of compiling it). Which would be rare.
By defualt, forms in VS (and express) use "partial classes"; this
means that there is a second file (Form1.Designer .cs) that is part of
the same class. But by changing the build action, the only file it can
find (for the Form1 class) is Form1.Designer. cs - which doesn't
explicitely know that it is a Form (this is part of Form1.cs), and
hence has no Dispose(bool) method to override.
Marc
OK, thanks.. but of course my example was just to give you the most simple
way to reproduce my problem (in case it was needed..).
but of course my real program is bigger than that and yes I have support
files (graphics) that I want to include.
so your answer seems to explain me why the examples I found online didn't
have this problem, because they was made with VS 2003 and there wasn't an
external Form1.designer. cs. that was simple example in only one file.
well, now, how can I make it go with "partial classes" if I set the build
action to embedded resource..?
thanks.
Fred
sorry, English is not my mother language and I think I replied a little too
fast, without reading what I wrote.. should have been clearer.
thanks again.
Fred
well, now, how can I make it go with "partial classes" if I set the build
action to embedded resource..?
Please can you explain *why* you want to set it as an embedded
resource? Basically, I'm pretty sure that this isn't going to do what
you think it is... so tell us what actually want to do, and we might
be able to suggest the right way to achieve it.
Marc
It is perfectly possible to add images; first, however, you need to
get the images into the project. Using Visual Studio (including
"express") you can drag files from Explorer into the solution explorer
(the tree with the files). Once the images are in the solution, there
are 2 ways to get access to them (in both cases, leave the build
action of the form as "compile")
The easiest option is to set the build action of the image(s) to
"content" (the default), and add a resource file (there may already by
one called Resources.resx) in the Properties folder. Open the resource
file (View Designer), and drag the image from the solution explorer
into the resource designer (anywhere... it doesn't matter). This tells
the compiler to embed the image into the resource file, which itself
will be embedded into the exe. You can now access the image by name,
simply by looking at ResourceFileNam e.ImageFileName - i.e. for me my
resource file is "Resources.resx ", and my image is "Test.jpg", so I
can use Resources.Test (which is an Image). Using the same example, if
it doesn't compile (The name 'Resources' does not exist in the current
context) then right-click on the Resources (underlined in blue in the
editor), Resolve -using [some namespace]. It should then work. Your
images should also now appear automatically when selecting button
images etc.
The second option is to change the build action of the image(s) to
"embedded resource"; however, it is trickier to get hold of these -
you need to use Assembly.GetMan ifestResourceSt ream({name}), and
process the stream manually.
Wow, I'm sorry, I think I got it.. I'm not near my PC with my C# project,
but it seems so evident to me just now, that it's a pity I didn't think of
it yesterday.
well I set the "embedded resource" build action to my Form1.cs, but I just
need to set this to the graphic files I need to embed, not to my Form..
many thanks again and sorry to eat your time for a so stupid error of mine..
Fred.
yes, with the resx file is really easy for what I need yet..
big thanks.
Fred This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Alexander May |
last post by:
Hi,
I love Python! I've been using it for a couple of years now and have found
it to be a highly productive language. I evangelize it to my developer
friends and am probably responsible for the sale of at least 10 Alex
Martelli books. I am now in the fortunate position of being able to use
Python for a large project, and as such I have a question.
We are developing a distributed application running on approximately six
thousand...
|
by: Saradhi |
last post by:
How to get the names of all the Resources embedded in a Resource File?
-SARADHI
|
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 deals with managed in one
place, and code that deals with unmanaged in another place, but I can't seem
to find anything that clearly explains what that means.
I think if I used a Windows API function to optain a handle, that handle
would be an...
|
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 generating a very simple installer
app that embeds referenced .dll files inside it, which are extracted and
referenced when the installer app is executed. This works great when the
installer app is built with Visual Studio .NET, but it does not work...
|
by: PromisedOyster |
last post by:
There are various contradictory newsgroup postings on this issue, but I
would really like a definitive answer from the .NET gurus out there?
We have various WinForms that contain multiple Icons and Bitmaps that
are loaded onto the form dynamically, eg control.Icon = ;. Should we
explicitly Dispose of these unmanaged resources when the form closes OR
should we leave it up to the garbage collector to remove these (and
will it definitively...
| |
by: Koliber (js) |
last post by:
sorry for my not perfect english
i am really f&*ckin angry
in this common pattern about dispose:
//////////////////////////////////////////////////////////
Public class MyClass:IDisposable
|
by: Varangian |
last post by:
Hello,
was wondering of how to dispose of managed resources?
or referencing every member of a class to null will release
resources...?
http://www.marcclifton.com/tabid/79/Default.aspx
http://www.codeproject.com/managedcpp/garbage_collection.asp - sources
|
by: steve |
last post by:
I have the following routine for retrieving error message strigs from a resource file which is embedded in the project. But when it
is called I get the error messsage "Could not find any resources.." shown underneath the code.
The error message indicates that it is looking for resource ResourceExceptions.resource which is not what was embedded in the code
by Visual Studio. The resource file is ResourceExceptions.resx.
If I try to change...
|
by: raylopez99 |
last post by:
I have the latest version of Visual Studio 2008 Professional, which
allows you to create resource files (this is the .resx file, no?),
unlike the Express version, which does not.
I am trying to cut and paste code that MSDN recommends for playing a
simple wav file from inside an embedded file, like presumeably the
'resources' file .resx is. I want to embed the .wav file in a
'resource file' since I don't want the user storing the file on...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |