Hi all,
I have a class in project A.
At the same solution, I have another project - named project B.
I want to write a piece of code in that class from project B that finds the
class in project A. How can I do that?
I have a code to do that, if the class is in the same project (by using
Application.Pro ductName, but even if I chaned it to the second project name,
its didn't work), and I've referenced it because I have some froms that I
inherited from project A..
:
Code:
Function GetFormByName(B yVal stFileName As String) As Form
Dim tFormType As Type = Type.GetType(st FileName, False)
If tFormType Is Nothing Then
Dim Fullname As String = Application.Pro ductName & "." &
stFileName
tFormType = Type.GetType(Fu llname, False, True)
If tFormType Is Nothing Then
Throw New Exception(stFil eName + " could not be found")
End If
End If
Return CType(Activator .CreateInstance (tFormType), Form)
End Function
Thanks 5 1339
Ohad
Simple use one the reference box which you can find in the Solution explorer
at top of a project of in the Project menu.
You can directly point to the other project in your solution, or to the DLL
that it has created.
Be aware that you have to in the Build options which projects and in what
other they have to be build.
As well, don't forget to set the Import directive to your namespace.
Otherwise you have to set that everytime in your code.
Cor
"Ohad weiss" <oh***@netvisio n.net.ilschreef in bericht
news:eu******** ******@TK2MSFTN GP03.phx.gbl...
Hi all,
I have a class in project A.
At the same solution, I have another project - named project B.
I want to write a piece of code in that class from project B that finds
the class in project A. How can I do that?
I have a code to do that, if the class is in the same project (by using
Application.Pro ductName, but even if I chaned it to the second project
name, its didn't work), and I've referenced it because I have some froms
that I inherited from project A..
:
Code:
Function GetFormByName(B yVal stFileName As String) As Form
Dim tFormType As Type = Type.GetType(st FileName, False)
If tFormType Is Nothing Then
Dim Fullname As String = Application.Pro ductName & "." &
stFileName
tFormType = Type.GetType(Fu llname, False, True)
If tFormType Is Nothing Then
Throw New Exception(stFil eName + " could not be found")
End If
End If
Return CType(Activator .CreateInstance (tFormType), Form)
End Function
Thanks
Thanks for the reply Cor,
But the project I'm trying to find its class (Project A) is of type Exe and
not Dll.
Therefore, I can't add a reference to it.
Ohad
"Cor Ligthert[MVP]" <no************ @planet.nlwrote in message
news:4B******** *************** ***********@mic rosoft.com...
Ohad
Simple use one the reference box which you can find in the Solution
explorer at top of a project of in the Project menu.
You can directly point to the other project in your solution, or to the
DLL that it has created.
Be aware that you have to in the Build options which projects and in what
other they have to be build.
As well, don't forget to set the Import directive to your namespace.
Otherwise you have to set that everytime in your code.
Cor
"Ohad weiss" <oh***@netvisio n.net.ilschreef in bericht
news:eu******** ******@TK2MSFTN GP03.phx.gbl...
>Hi all,
I have a class in project A. At the same solution, I have another project - named project B.
I want to write a piece of code in that class from project B that finds the class in project A. How can I do that?
I have a code to do that, if the class is in the same project (by using Application.Pr oductName, but even if I chaned it to the second project name, its didn't work), and I've referenced it because I have some froms that I inherited from project A.. :
Code: Function GetFormByName(B yVal stFileName As String) As Form Dim tFormType As Type = Type.GetType(st FileName, False) If tFormType Is Nothing Then Dim Fullname As String = Application.Pro ductName & "." & stFileName tFormType = Type.GetType(Fu llname, False, True) If tFormType Is Nothing Then Throw New Exception(stFil eName + " could not be found") End If End If Return CType(Activator .CreateInstance (tFormType), Form) End Function
Thanks
Ohad
Then why not simple make a DLL from it?
Cor
"Ohad weiss" <oh***@netvisio n.net.ilschreef in bericht
news:eY******** ******@TK2MSFTN GP03.phx.gbl...
Thanks for the reply Cor,
But the project I'm trying to find its class (Project A) is of type Exe
and not Dll.
Therefore, I can't add a reference to it.
Ohad
"Cor Ligthert[MVP]" <no************ @planet.nlwrote in message
news:4B******** *************** ***********@mic rosoft.com...
>Ohad
Simple use one the reference box which you can find in the Solution explorer at top of a project of in the Project menu.
You can directly point to the other project in your solution, or to the DLL that it has created. Be aware that you have to in the Build options which projects and in what other they have to be build.
As well, don't forget to set the Import directive to your namespace. Otherwise you have to set that everytime in your code.
Cor
"Ohad weiss" <oh***@netvisio n.net.ilschreef in bericht news:eu******* *******@TK2MSFT NGP03.phx.gbl.. .
>>Hi all,
I have a class in project A. At the same solution, I have another project - named project B.
I want to write a piece of code in that class from project B that finds the class in project A. How can I do that?
I have a code to do that, if the class is in the same project (by using Application.P roductName, but even if I chaned it to the second project name, its didn't work), and I've referenced it because I have some froms that I inherited from project A.. :
Code: Function GetFormByName(B yVal stFileName As String) As Form Dim tFormType As Type = Type.GetType(st FileName, False) If tFormType Is Nothing Then Dim Fullname As String = Application.Pro ductName & "." & stFileName tFormType = Type.GetType(Fu llname, False, True) If tFormType Is Nothing Then Throw New Exception(stFil eName + " could not be found") End If End If Return CType(Activator .CreateInstance (tFormType), Form) End Function
Thanks
Because its another exe project.
I'll try to explain:
I have a project that its results is dll. It contains that main app form(mdi
paren), login form, and general form. This project result a dll file.
In the same solution I have another 2 projects that their result is exe file
(each on of them). tese two projects has classes that inherit from the
general form in the project that created the dll.
In one of my classes in the exe projects, I need to scan a class in the
second exe project and retrieve the controls on it. This is why I cant use
it as a dll.
Is there any way to set reference to an exe project?
If I change the second param in the function tFormType =
Type.GetType(Fu llname, False, True) to true, I get an exception about the
assembly:
Could not load type X from assembly Y, version=1.0.... , culture=neutral ,
publickeytoken= null.
X- the path and the fulename I'm trying to retrive (which is in project X)
Y - the name of project Y from which I'm trying to call the form in the
second project
Is there any way to set reference to an exe project? Or maybe you can
explain me how to set another assembly to the project
I can send the code if needed.
Thanks Ohad
"Cor Ligthert[MVP]" <no************ @planet.nlwrote in message
news:19******** *************** ***********@mic rosoft.com...
Ohad
Then why not simple make a DLL from it?
Cor
"Ohad weiss" <oh***@netvisio n.net.ilschreef in bericht
news:eY******** ******@TK2MSFTN GP03.phx.gbl...
>Thanks for the reply Cor, But the project I'm trying to find its class (Project A) is of type Exe and not Dll. Therefore, I can't add a reference to it.
Ohad
"Cor Ligthert[MVP]" <no************ @planet.nlwrote in message news:4B******* *************** ************@mi crosoft.com...
>>Ohad
Simple use one the reference box which you can find in the Solution explorer at top of a project of in the Project menu.
You can directly point to the other project in your solution, or to the DLL that it has created. Be aware that you have to in the Build options which projects and in what other they have to be build.
As well, don't forget to set the Import directive to your namespace. Otherwise you have to set that everytime in your code.
Cor
"Ohad weiss" <oh***@netvisio n.net.ilschreef in bericht news:eu****** ********@TK2MSF TNGP03.phx.gbl. .. Hi all,
I have a class in project A. At the same solution, I have another project - named project B.
I want to write a piece of code in that class from project B that finds the class in project A. How can I do that?
I have a code to do that, if the class is in the same project (by using Application. ProductName, but even if I chaned it to the second project name, its didn't work), and I've referenced it because I have some froms that I inherited from project A.. :
Code: Function GetFormByName(B yVal stFileName As String) As Form Dim tFormType As Type = Type.GetType(st FileName, False) If tFormType Is Nothing Then Dim Fullname As String = Application.Pro ductName & "." & stFileName tFormType = Type.GetType(Fu llname, False, True) If tFormType Is Nothing Then Throw New Exception(stFil eName + " could not be found") End If End If Return CType(Activator .CreateInstance (tFormType), Form) End Function
Thanks
Ohad,
Then you have simple first to splits that "other" project.
Cor
"Ohad weiss" <oh***@netvisio n.net.ilschreef in bericht
news:eg******** ******@TK2MSFTN GP03.phx.gbl...
Because its another exe project.
I'll try to explain:
I have a project that its results is dll. It contains that main app
form(mdi paren), login form, and general form. This project result a dll
file.
In the same solution I have another 2 projects that their result is exe
file (each on of them). tese two projects has classes that inherit from
the general form in the project that created the dll.
In one of my classes in the exe projects, I need to scan a class in the
second exe project and retrieve the controls on it. This is why I cant use
it as a dll.
Is there any way to set reference to an exe project?
If I change the second param in the function tFormType =
Type.GetType(Fu llname, False, True) to true, I get an exception about the
assembly:
Could not load type X from assembly Y, version=1.0.... , culture=neutral ,
publickeytoken= null.
X- the path and the fulename I'm trying to retrive (which is in project X)
Y - the name of project Y from which I'm trying to call the form in the
second project
Is there any way to set reference to an exe project? Or maybe you can
explain me how to set another assembly to the project
I can send the code if needed.
Thanks Ohad
"Cor Ligthert[MVP]" <no************ @planet.nlwrote in message
news:19******** *************** ***********@mic rosoft.com...
>Ohad
Then why not simple make a DLL from it?
Cor
"Ohad weiss" <oh***@netvisio n.net.ilschreef in bericht news:eY******* *******@TK2MSFT NGP03.phx.gbl.. .
>>Thanks for the reply Cor, But the project I'm trying to find its class (Project A) is of type Exe and not Dll. Therefore, I can't add a reference to it.
Ohad
"Cor Ligthert[MVP]" <no************ @planet.nlwrote in message news:4B****** *************** *************@m icrosoft.com... Ohad
Simple use one the reference box which you can find in the Solution explorer at top of a project of in the Project menu.
You can directly point to the other project in your solution, or to the DLL that it has created. Be aware that you have to in the Build options which projects and in what other they have to be build.
As well, don't forget to set the Import directive to your namespace. Otherwise you have to set that everytime in your code.
Cor
"Ohad weiss" <oh***@netvisio n.net.ilschreef in bericht news:eu***** *********@TK2MS FTNGP03.phx.gbl ... Hi all, > I have a class in project A. At the same solution, I have another project - named project B. > I want to write a piece of code in that class from project B that finds the class in project A. How can I do that? > I have a code to do that, if the class is in the same project (by using Application.Pro ductName, but even if I chaned it to the second project name, its didn't work), and I've referenced it because I have some froms that I inherited from project A.. : > > Code: Function GetFormByName(B yVal stFileName As String) As Form Dim tFormType As Type = Type.GetType(st FileName, False) If tFormType Is Nothing Then Dim Fullname As String = Application.Pro ductName & "." & stFileNam e tFormType = Type.GetType(Fu llname, False, True) If tFormType Is Nothing Then Throw New Exception(stFil eName + " could not be found") End If End If Return CType(Activator .CreateInstance (tFormType), Form) End Function > Thanks > > This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Chi Tang |
last post by:
Hi,
I have 2 questions:
How to call a class member function from another class and these 2 classes
are in the same namespace?
Also, how to use another project's dialog box and this 2 projects are in the
same VS.NET solution?
|
by: Brian Reed |
last post by:
I have three projects in the same solution that are all class library
projects. The projects are COM interop objects that will be used within my
COM framework. It is important to me to have all three projects building to
the bin directory of my COM framework so that I don't have to use the
/codebase option when registering the objects.
Here is my problem, all three projects reference the same COM typelib, which
will generate an...
|
by: Brett P |
last post by:
Hello,
I am a C# developer working for a state agency. We
are currently trying to come up with a standard approach
for using Visual Source Safe (VSS). I have read the team
development articles on MSDN for Microsoft's
recommendation, which I agree with. But, there is some
resistance at my organization. Many of the developers
are not for source controlling solution files, which
means the developer would maintain his own solution on...
|
by: Robert W. |
last post by:
I'm building a simple application that consists of two projects:
- Desktop
- DataObjects
'Desktop' consists of the forms for the app whereas 'DataObjects' consists
of utility classes that will be used by 'Desktop' and other projects .
Whenever I add a new class to 'DataObjects', no matter what I do - ie. Build
and/or Rebuild - it doesn't seem to update the reference into Desktop. The
only way I can get this to occur is to close...
|
by: z. f. |
last post by:
Hi,
I'm working on a web project and i create classes to do business logic and
connect to DB.
i also need a windows application to do the same functionality as defined
in classes inside the ASP.NET project.
when i reference the web project DLL (inside the BIN directory) I
successfully make a call to a function and get return value.
but this is just a test and when trying to access the application
| |
by: Brian Shannon |
last post by:
I am playing around with class libraries trying to understand how they work.
I created a class library, library.vb.
I placed the library.dll into the bin directory and set my reference.
If I update the library.dll can I Just place the new .dll in the bin
directory or do I need to recompile my program.
During testing I am just placing the new library.dll in the bin directory
and don't get any of the updates I made until I re-reference...
|
by: koffieautomaat |
last post by:
I've made one solution containing two projects.
The first projects contains a control libary (dll) with a reusable
class.
The other projects contains a from which i wanna talk to the dll made
by the first project.
I've set the dependency from the other project to the first with the
solution explorer.
Only the Intellisense can't find the class in the list?
What am I doing wrong?
|
by: semedao |
last post by:
Hi All,
I developed Outlook add-in with VS 2005 , everything work fine , until the
machine reboot unnormally , when I opened the solution again
many projects was not there ! (I have more then 10 project that depends each
other).
I add them again , also add the primary output again to the setup project.
|
by: shapper |
last post by:
Hello,
I am working with VS 2008 and created a Web Application Project.
I added a class but whatever I do the class is not visible to my aspx
pages or anywhere else.
I then changed the property Build Action in my class from Content to
Compile. Now it is recognized.
|
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: 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: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |