Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Using a form, from a dll, to maintain properties in My.Settings

Posted on 2012-03-18
14
Medium Priority
?
214 Views
Last Modified: 2012-04-09
Friends,

I have a document (attached to this question) that outlines the code I am using, and that some how  I want to include in my other projects (as a dll).  The end result, is that I want allow my users to update their data source names in the programs they use (which is what the dll is intended to do).

This works great for the Data Source Names (dsn) that are included in the dll's project, but if I include this project (as a dll), it won't reference the values in the parent program's My.Settings list.  It is still looking for a list of My.Settings for the local project (dll).

By this, I mean that I run a program (ex. Project 1) that uses the DSNMaintenance dll.  I want the DSNMaintenance.dll to look at Project 1's My.Setting list, and not it's own.  

Now, I could just include the form from the project, and it works great, but, if I wanted to make a change to that form, I'd have to update it in every project I use.

What do I need to change in my DSNMaintenance project to expose the My.Settings list of the parent project that references the dll?

Looking for VB.net syntax help, please!

Thanks in advance!
DSNMaintenanceCode.docx
0
Comment
Question by:indy500fan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 6
14 Comments
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37734937
0
 

Author Comment

by:indy500fan
ID: 37734954
CodeCruiser,

In a nutshell, is this saying that I need to build my list of settings in my main project, and then pass that to my dll?

If so, can you help me with the building of the list to pass?
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37735008
I think you can define a property in the DLL which you form can access so you set it equal to my.settings at runtime before showing the form.
0
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 

Author Comment

by:indy500fan
ID: 37735068
Code Cruizer,

Can you help me with that syntax help, please?
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 1500 total points
ID: 37735158
In DLL

Public class ...

Public Property AppSettings As Object

Then in form

Dim set as New classname
set.AppSettings = My.Settings
...
0
 

Author Comment

by:indy500fan
ID: 37735168
Uh...sorry...a little more help, please?

You have to remember, I wasn't that great a developer before, and it's been two years since I've done this.  

What goes where?  My form is in my DLL, so I'm not sure which you are referring to.
0
 

Author Comment

by:indy500fan
ID: 37735422
Code Cruizer...

Is it possible that you haven't looked at my specific example?  I appreciate that you help a lot of people, but I said from the beginning that I was looking for VB.net syntax help, and I would appreciate help for my specific example.

I am looking up all the Settings, that contain the string dsn, and then putting them into a list, not just a single know property as it seems in the link you gave me.

Does that help you to understand where I am coming from?

Best Regards,
Eric
0
 

Author Comment

by:indy500fan
ID: 37737230
Code Cruizer,

You there?
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37740206
Yes. The code I wrote was mainly suedo code to give you an idea.

The main idea is that you need to pass the reference of your My.Settings class into the DLL somehow. So if you have a form in DLL, you need to define a public property on that form and then set this property to My.Settings at runtime before you show the form so that form is able access the settings indirectly.
0
 

Author Comment

by:indy500fan
ID: 37740218
Can you create the code for the Property?  I'm not sure how to implement a property for the My.Settings as you describe.  I think I might be able to figure out the rest after that.
0
 
LVL 83

Expert Comment

by:CodeCruiser
ID: 37740271
I already did


Public Property AppSettings As Object


Its object because My.Settings is dynamic. You can still use the

AppSettings.MySetting = value

as you as you are sure that settings exists.
0
 

Author Comment

by:indy500fan
ID: 37758301
CodeCruiser,

Okay, let me be VERY specific...Can you write the rest of the Property code.

including the Get and Set, please.

Eric
0
 
LVL 83

Accepted Solution

by:
CodeCruiser earned 1500 total points
ID: 37769205
There is no need for that with the auto implemented properties. If you want to go that route then

private _AppSettings As Object
Public Property AppSettings As Object
Get
   Return _AppSettings
End Get
Set(Value As Object)
   _AppSettings = Value
End Set
End Property
0
 

Author Comment

by:indy500fan
ID: 37770693
I will try this tonight or tomorrow.  Thanks!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question