Solved

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

Posted on 2016-07-18
7
29 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
  • 3
  • 2
  • 2
7 Comments
 
LVL 62

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 32

Accepted Solution

by:
sarabande earned 500 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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 62

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 32

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 32

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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

758 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now