Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / June 2007

Tip: Looking for answers? Try searching our database.

Reference Application Variables Inside DLL

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
pauld@maronsoftware.com - 14 Jun 2007 16:27 GMT
I want to be able to access some global variables (defined in a
winforms "ApplicationEvents.vb") from a DLL.

I assume I need to pass a reference to the application object to the
DLL.  If so, how would I define it in the DLL and how would I set it
in the main app?

Is there some other way to get a reference to the DLL instantiator's
application object from inside the DLL?

Thanks.

I RECEIVED A PRIOR RESPONSE THAT I DIDN'T UNDERSTAND:
Declare the global variables as public and shared:

Namespace SomeNamespace
Public Class SomeClassName

Public Shared SomeVariableField As Integer = 3

End Class
End Namespace

Then, inside the DLL access the variables like this:

Dim i As Integer = SomeNamespace.SomeClassName.SomeVariableField
geoffrey.munday@gmail.com - 14 Jun 2007 17:11 GMT
Paul,

You need to ensure you've added a reference to the assembly that
contains your static/shared property or field variable to the
"project" that will need to use the value.  You can do this by
accessing the "References" tab on the project properties screen in
Visual Studio and clicking "Add".  Look into "Adding project or
assembly references to projects" on MSDN or the web for more info.

After you add the assembly reference to the project that wants to
reference the variable you then refer to it using a fully qualifed
name as demonstrated in someone's previous response to your original
post.  For example:

Dim myLocalString =
MyReferencedAssemblyNamespace.MyClassInThatAssembly.MySharedStringVariable

I believe your problem is largely due to not having the assembly
referenced in your project.

HTH,
Geoff

On Jun 14, 11:27 am, p...@maronsoftware.com wrote:
> I want to be able to access some global variables (defined in a
> winforms "ApplicationEvents.vb") from a DLL.
[quoted text clipped - 22 lines]
>
> Dim i As Integer = SomeNamespace.SomeClassName.SomeVariableField
Michael C - 15 Jun 2007 04:33 GMT
>I want to be able to access some global variables (defined in a
> winforms "ApplicationEvents.vb") from a DLL.
[quoted text clipped - 5 lines]
> Is there some other way to get a reference to the DLL instantiator's
> application object from inside the DLL?

You can't. Anything the dll needs to access will need to be passed into the
dll. You can't pass in an app object because the dll won't know what your
app object is. Something is wrong with your approach, can you give more
details of what you're trying to do.

> I RECEIVED A PRIOR RESPONSE THAT I DIDN'T UNDERSTAND:

Whoever wrote this response didn't understand the question (unless it is me
who didn't understand :-)

Michael

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.