473,405 Members | 2,300 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,405 software developers and data experts.

using Forms in a DLL



I have a simple managed DLL that contains a basic cMap class. The root namespace is Map. Also in the DLL is a form for viewing it (frmViewMap), along with a toolbar, menu's and the like.

I've created a second project that will use this dll. I'm trying to inherit off of cMap (Basically adding stuff to it). I also created a new class for viewing, which inherits from frmViewMap. When I try to edit the form (to add additional buttons), I get the following error:
"An exception occured while trying to create an instance of Map.frmViewMap. The exception was "Could not find any resources appropriate for the specified culture in the given assemply. Make sure "frmViewMap.resources" was correctly enbedded or linked into assembly "Map"."

If I try to run my second project, it crashes (Unhandled exception) in InitializeComponent in frmViewMap (in the DLL), where it tries to create the image list for the toolbar:
this->ilMainToolb->ImageStream = (__try_cast<System::Windows::Forms::ImageListStrea mer * >(resources->GetObject(S"ilMainToolb.ImageStream")));

If I use ildasm.exe on the DLL, and open up MANIFEST, there is a section that says: .mresource public Map.frmViewMap.resources{}. This tells me that it is being included in the DLL. There are no other classes or enums or anything being declared in the same file as frmViewMap or the class that is inheriting.

Where am I going wrong??? I've tried googling it, but I can't find my problem. I've tried several of the solutions, but so far, none of them have worked.

Thanks for any help or poiters..

GE
Nov 17 '05 #1
6 1076
Hi,

for me the problem was with the settings in Project->Properties->Managed
Resources->General->Resource File Name
The original value was
$(IntDir)/$(RootNamespace).$(SafeInputName).resources

After I changed it to
$(IntDir)/$(RootNamespace).$(InputName).resources

I had no further trouble with that.

The problem with $(SafeInputName) was it changed names like
"AppStrings.en" to "AppStringsen". This messed things up.

Hope that helps,

Martin
Fireangel wrote:

I have a simple managed DLL that contains a basic cMap class. The root namespace is Map. Also in the DLL is a form for viewing it (frmViewMap), along with a toolbar, menu's and the like.

I've created a second project that will use this dll. I'm trying to inherit off of cMap (Basically adding stuff to it). I also created a new class for viewing, which inherits from frmViewMap. When I try to edit the form (to add additional buttons), I get the following error:
"An exception occured while trying to create an instance of Map.frmViewMap. The exception was "Could not find any resources appropriate for the specified culture in the given assemply. Make sure "frmViewMap.resources" was correctly enbedded or linked into assembly "Map"."

If I try to run my second project, it crashes (Unhandled exception) in InitializeComponent in frmViewMap (in the DLL), where it tries to create the image list for the toolbar:
this->ilMainToolb->ImageStream = (__try_cast<System::Windows::Forms::ImageListStrea mer * >(resources->GetObject(S"ilMainToolb.ImageStream")));

If I use ildasm.exe on the DLL, and open up MANIFEST, there is a section that says: .mresource public Map.frmViewMap.resources{}. This tells me that it is being included in the DLL. There are no other classes or enums or anything being declared in the same file as frmViewMap or the class that is inheriting.

Where am I going wrong??? I've tried googling it, but I can't find my problem. I've tried several of the solutions, but so far, none of them have worked.

Thanks for any help or poiters..

GE

Nov 17 '05 #2

Hi,

try this one:

System::Reflection::Assembly *asmP3D = this->GetType()->Assembly;
String *str[] = asmP3D->GetManifestResourceNames();

for(int i=0; i<str->Length; i++)
{
MessageBox::Show(str[i]);
}

Check out what happens - this will show you all resource names inside
your dll. Have you tried to set the name of the resource to some fixed
value(like $(IntDir)/$(RootNamespace).Pics.resources)?

When I started with VC.NET I made the following mistake:
I named the resX-file something like myNS.Pics.resX (instead of
Pics.resX) this resulted in a name I wasn't able to load.

If this all doesn't help - my very last attempt was to create an empty
project and insert all the files again - and (for whatever reason) the
solution worked fine afterwards....
Hope this helps,

Martin Peter Hanke
Nov 17 '05 #3
Its there. But it looks like there ain't nothing in it (Which is probably why the image stream throws an exception when trying to make it).

I think I'm going to go a different route. Just don't know which one yet. This seams to me to be a rather simple problem, but either nobody else has tried doing things this way, or nobody knows the solution. Big pain in my side either way....

Thanks for your help. And good luck on your problem....

GE

"mphanke" wrote:

Hi,

try this one:

System::Reflection::Assembly *asmP3D = this->GetType()->Assembly;
String *str[] = asmP3D->GetManifestResourceNames();

for(int i=0; i<str->Length; i++)
{
MessageBox::Show(str[i]);
}

Check out what happens - this will show you all resource names inside
your dll. Have you tried to set the name of the resource to some fixed
value(like $(IntDir)/$(RootNamespace).Pics.resources)?

When I started with VC.NET I made the following mistake:
I named the resX-file something like myNS.Pics.resX (instead of
Pics.resX) this resulted in a name I wasn't able to load.

If this all doesn't help - my very last attempt was to create an empty
project and insert all the files again - and (for whatever reason) the
solution worked fine afterwards....
Hope this helps,

Martin Peter Hanke

Nov 17 '05 #4

I finally got mine to work (After amonth of fiddle with is). My project name was MAP, and the root namespace I was using was ROFMap (Important). So the form in question was ROFMap::frmViewMap. The second EXE (Which was inheriting from frmViewMap) was actually looking for RootNamespace.FormName.resources (ROFMAP.frmViewMap.resources). It couldn't find this, because the rootnamespace is taken from the projectname (MAP). So my second project was looking for MAP.frmViewMap.resources.

I went back and renamed my initial DLL project to ROFMap, and recompiled. Everything came up the first time (Well, after the thunderstorm messed with my puters).

For your project to work, your project name has to be TESTNS. I would change this to your project name and try again (or at least make sure the rootnamespace matches).

GE

PS> If you look in the dll, the manifest will not show exactly what resources are in it.

"mphanke" wrote:

Hi,

try this one:

System::Reflection::Assembly *asmP3D = this->GetType()->Assembly;
String *str[] = asmP3D->GetManifestResourceNames();

for(int i=0; i<str->Length; i++)
{
MessageBox::Show(str[i]);
}

Check out what happens - this will show you all resource names inside
your dll. Have you tried to set the name of the resource to some fixed
value(like $(IntDir)/$(RootNamespace).Pics.resources)?

When I started with VC.NET I made the following mistake:
I named the resX-file something like myNS.Pics.resX (instead of
Pics.resX) this resulted in a name I wasn't able to load.

If this all doesn't help - my very last attempt was to create an empty
project and insert all the files again - and (for whatever reason) the
solution worked fine afterwards....
Hope this helps,

Martin Peter Hanke

Nov 17 '05 #5
I know this thread is old but I had the same problem and I hit a bunch of boards to find the answer. I finally found the answer to my problem and thought I would share it.

Drum roll please.......The form class must be the first class defined in the form's .cs file. You can't have a helper class or enum defined before it.

More info at: http://support.microsoft.com/default...;en-us;Q318603

Peter Thomas

---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
Nov 17 '05 #6
If you think to go back and look at this, or for those of you who stumbled accros this before finding the real answer to this mysterious problem, try seeing if this article resolves your issue.

The short answer, don't put ANY time in front of your Form class in its own file. Full details in the referenced article.

http://support.microsoft.com/default...;en-us;Q318603

Richard Grenfell

---
Posted using Wimdows.net NntpNews Component -

Post Made from http://www.DotNetJunkies.com/newsgroups Our newsgroup engine supports Post Alerts, Ratings, and Searching.
Nov 17 '05 #7

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

Similar topics

6
by: Billy Jacobs | last post by:
I have a website which has both secure and non-secure pages. I want to uses forms authentication. How do I accomplish this? Originally I had my web.config file in the root with Forms...
0
by: grutta | last post by:
I am writing a windows service that will recieve notification when a USB Device is insterted into the machine. I have used the RegisterDeviceNotification and the RegisterServiceCtrlHandlerEx with...
5
by: Dave | last post by:
I tried posting this in the WinForm forum and got no hits so I am trying it here. After inserting a new data row to a DataTable that is bound to a datagrid, I am unable to change data in a row...
19
by: James Fortune | last post by:
I have a lot of respect for David Fenton and Allen Browne, but I don't understand why people who know how to write code to completely replace a front end do not write something that will automate...
0
by: Marco Segurini | last post by:
Hi, I am trying to dynamically install/deinstall a message handler to a System.Windows.Forms.Form using NativeWindow. I do not use IMessageFilter derived class because it intercept only the...
2
by: Hrcko | last post by:
How to use this control? I have to grids on my form, one on the top and one on bottom. When I start application I want to be able to move bottom grip up, and top grid down, but it doesn't...
3
by: Rob | last post by:
Hi all, I am having trouble converting the code below (found on http://vbnet.mvps.org/index.html?code/core/sendmessage.htm) into a format that will work using vb .NET. Can anyone have a look...
3
by: Siv | last post by:
Hi, A little while ago I wrote a small program that allowed the user to view products from a database. The database holds the details of the products which can be viewed via a form and...
0
by: Sister Ray | last post by:
I'm trying to create a simple form that sends an email using my company's exchange server. I'm using the System.Net.Mail Namespace of the .net framework 2.0. I've googled everywhere and i think my...
19
Atli
by: Atli | last post by:
Introduction At some point, all web developers will need to collect data from their users. In a dynamic web page, everything revolves around the users input, so knowing how to ask for and collect...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
marktang
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,...
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...
0
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...
0
tracyyun
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.