?
Solved

Adding data to a DLL and using the DLL in a c# program

Posted on 2016-07-18
7
Medium Priority
?
37 Views
Last Modified: 2016-07-19
I have a dll that holds all of our connection strings.  I can use this dll in all my other programs.  I have no problem accessing any information in this dll currently.

Now I need to add a connection string and I am getting an error:

'BaseClassLibrary.Cm' does not contain a definition for 'cpt'.

FYI - 'cpt' is the new connection string.  

I am using Visual Studio 2012.  Do I need to remove the dll from my project and then add it again?  

Here is how I call the data that is in the dll:

Cm.ex(Cm.cpt, strSQL, null, ch, "BaseClassLibrary.At", at, null, null, null, null, true);

Open in new window



When I click on the 'Cm' and hit F12 I am taken to a page with this code.
using System;
using System.Collections;
using System.Windows.Forms;

namespace BaseClassLibrary
{
    public class Cm
    {
        public static string cp;
        public static string plc;
        public static string pld;
        public static string pldt;
        public static string plw;

        public Cm();

        public static string ex(string cmm, string fc, string cmt, Hashtable ch, string ot, Ob rob, ArrayList al, Ts gts, Dl gdl, Label rl, bool q);
    }
}

Open in new window


I try to add:
public static string cpt;

Open in new window


but I am unable to write in this file.  How can I do this?
0
Comment
Question by:huerita37
[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
  • 3
  • 2
  • 2
7 Comments
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 41718031
You state, "but I am unable to write in this file.  How can I do this? ", what error are you getting when you try to modify the file with that line of code?
0
 
LVL 35

Accepted Solution

by:
sarabande earned 2000 total points
ID: 41718226
as far as i can see  from your snippet, you need to add static member

public static string cpt;

Open in new window


to the class.

probably you also have to define the connection string somewhere in the code.

Sara
0
 

Author Comment

by:huerita37
ID: 41719323
Fernando:  I am adding:

public static string cpt;

I have gone into the BaseClassLibrary project and I save it but when I look at the different projects that call BaseClassLibrary it is not there.
0
Quiz: What Do These Organizations Have In Common?

Hint: Their teams ended up taking quizzes, too.

 

Assisted Solution

by:huerita37
huerita37 earned 0 total points
ID: 41719369
I opened the BaseClassLibrary project and made my changes in there.  I clicked 'Build Solution' but it was pointing to the 'Debug' folder and not the 'Release' folder.  Once I changed that I was able to see my changes in my other projects.
0
 
LVL 63

Expert Comment

by:Fernando Soto
ID: 41719375
When you added the BaseClassLibrary.dll to the project that is using it, please right click on that dll in the Reference node in Solution Explorer select Properties from the short cut menu and make sure that the property "Copy Local" is set to True.
0
 
LVL 35

Expert Comment

by:sarabande
ID: 41719379
I have gone into the BaseClassLibrary project and I save it
... and where the connect string was set? check how the other connect strings were handled and do the same for 'cpt' variable.

but it was pointing to the 'Debug' folder and not the 'Release' folder.
you should do the build for both Debug and Release configuration.


Sara
1
 
LVL 35

Expert Comment

by:sarabande
ID: 41719393
Huerita,

if you wanted to share the points between Fernando and me, you may click at the 'Request Attention' button at the bottom of your original post.

Sara
1

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…
Suggested Courses

762 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