|
In a C# 2010 windows application, I am getting the following error message:
"The connection property in the Application Settings file is missing or incorrect. The connection string from the .dbml file has been used in its place".
I am also getting the warning message: warning CS0618: 'System.Configuration.ConfigurationSettings.AppSettings' is obsolete: 'This method is obsolete,
it has been replaced by System.Configuration!System.Configuration.ConfigurationManager.AppSettings".
What I am trying to do is obtain the connection string information from the app.configuration file instead from the app settings file.
To accomplish this goal I am chanigng the *designer.cs to use the following code to obtain the connection string information:
base(ConfigurationManager.ConnectionStrings["DEVConnectionString"].ConnectionString, mappingSource)
The app.configuration file looks like the following:
<connectionStrings>
<add name="DEVConnectionString" connectionString="Data Source=dev2008;Initial Catalog=DEV;Integrated Security=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
The above code works fine when I setup the code initially.
However once I reopen the soltuion file, I get the message listed above,
""The connection property in the Application Settings file is missing or incorrect.
The connection string from the .dbml file has been used in its place".
To solve this problem, I was trying to do the following steps:
1.Step 1: Right click on the .DBML file and select "Run Custom Tool".
2.Step 2: Set "Application setting = false" in the connecton properties of your DataContext.
3.Step 3: press "Save All".
The problem with the above solution is once I selected "Run Custom Tool", nothing happened. There was nothing for me to select.
Thus can you tell me and/or show me in code how to solve this problem?
|
|
|
|
|
Don't try to edit *.designer.cs files as they are built and rebuilt by Visual Studio. If you want to access information in this way then you need to add the actual code into your main program.
|
|
|
|
|
I've just started learning C# yesterday, and I'm really confused with the reference system.
Can anyone please help explain to me what would happen here:
class Population{
public void DuplicatePopulation(Population thatPop){
x=thatPop.x;
}
public int x;
};
class GA{
public GA(){
InitPop=new Population();
CrossOverPop=new Population();
}
public Population FindPopID(int ID){
switch(ID){
case 1:return InitalPop;break;
case 2:return CrossOverPop;break;
default:break;
}
return InitialPop;
}
public void DuplicatePopulation(int FromID,int ToID){
Population FROM,TO;
FROM=FindPopID(FromID);
TO=FindPopID(ToID);
TO.DuplicatePopulation(FROM);
}
Population InitialPop,CrossOverPop;
};
class MainClass{
public void main(string[] args){
GA GeneticAl=new GA();
GeneticAl.DuplicatePopulation(1,2);
};
What I'm trying to do is duplicate population Init to Population CO. With this code, will the value of CrossOverPop.x == InitPop.x
Am I already passing by reference? or did i need to use the ref keyword?
|
|
|
|
|
All objects are inherently reference types i.e. they are passed around by reference.
So you don't need the ref key to pass them around.
|
|
|
|
|
The ref keyword has a special meaning when applied to reference types. When ref is applied to a reference type, you can actually make the variable point to a different object altogether. Passing without the ref keyword (the default) will only allow you to change the state of the object, you cannot make it point to a different object.
|
|
|
|
|
I'm making a GUI for a device. The connection goes across a bluetooth USB device.
Part of the process is to connect to the device.
The user clicks a button to make that connection.
When I encounter an error with the Serial Port, such as...
Semaphore TimeOut Expired
What do I tell the user to do ?
|
|
|
|
|
It depends on you design your application and how you managed your device classes. You can display understandable and friendly message to the user because most of the end users are No-wise operator. If you try to display technical errors in your message this will confuse them so a friendly message and if possible what to do next.
for eg: in this case you can show "Failed to connect to the device. Please try again" you can use the same message for any error that related to the connection and write the actual error in your log file so that field engineer or programmer can check the real problem from the log files.
Jibesh V P
|
|
|
|
|
We are creating a Software's extension dll. Here we will be using the Software's base dll which will be there in Software's Installed Location. But the extension dll will be installed inside a subfolder(Extensions) of the Software's Installed Location. In code i have added the Software's base dll reference and developed the code. Now what happens is the Software's base dll is copied inside the subfolder(Extensions) also which is not accepted. I should only take the Software's base dll from Software's Installed Location.
As the Software's Installed Location can be anything, how can i add dynamic reference to the Software's base dll. Please help.
|
|
|
|
|
Can you clarify with examples, where the various components of your application, are located. Also add the exact error messages you see.
e.g.
Development configuration (working)
===================================
App.exe
BaseDll.dll
ExtensionDll.dll
Deployment configuration (not working?)
======================================
App.exe
Extensions\BaseDll.dll
Extensions\ExtensionDll.dll
System.IO.FileNotFoundException: Could not load file or assembly 'BaseDll...........
I assume that whatever you had on the development machine works correctly. If the same relative paths are used in the deployed application does it still work?
|
|
|
|
|
Question as written is hard to understand.
Presumably you have a delivery that looks like the following
<root dir>\MyApp
App.exe
Base.dll
.\Extension\
Extended.dll
And you are loading Extended dll dynamically.
In that case Extended dll should be built using Base.dll.
There are two possibilities there.
1. You have already referred to something in App.exe which is in Base.dll. And thus Base.dll will already be loaded into the process (AppDomain) space
2. You have not referred to Base.dll. In that case the .Net load process will attempt to search for Base.dll. Presuming it is not in GAC then it will search in the App.exe directory and thus it will find it. And load it.
The above presumes you haven't messed with anything including setting up your own AppDomains.
|
|
|
|
|
Hi,
Now I have two questions here.
1.
I am using the graphics object to create a customized report from a database. To ensure WYSIWIG, I use the same functions in the paint event of the panel with the printPage event of a PrintDocument after passing the necessary event arguments.
So far there is no trouble. Printing and previewing works just the way I want.
(NB - Did not use the printPreviewControl as I felt it was way slower than a panel. Don't know if I am right.)
So, Am I going the right way to create a WYSIWIG compliant application?
2.
I want to save the created report into a XML format. I used the XMLWriter class, and was almost succesful in saving the report. I was ready to pat myself in the back and call it a day when it occured that I knew no way to serialize a Brush object. All I want to store is just the brush color.
How can I get the color of a brush object? Because I don't see any properties exposed. Any workarounds?
modified 30-Jan-13 7:49am.
|
|
|
|
|
Here is an advanced print preview dialog/control[^]. That may help.
As for the brush, figure out the type (likely a solid brush), cast it to that type, and serialize the properties you want.
e.g. (for a solid brush)
if(brush is SolidBrush)
{
SolidBrush sb = (SolidBrush)brush;
}
else if(brush is LinearGradientBrush)
{
}
Bob Dole The internet is a great way to get on the net.
2.0.82.7292 SP6a
|
|
|
|
|
Thanks a lot.
Casting the brush object was exactly what I needed. So simple.
And yeah, it was a SolidBrush.
Will have to study the PrintPreviewControl article a bit though.
Thanks again.
|
|
|
|
|
hi,
i need help to check the avaialbility of username from database. i am developing this website in a .net 3 tier framework. i already search for coides through google but all the codes are in 2 tier based. please help..............
|
|
|
|
|
We can't give you any specifics, because you don't give us any specifics.
But basically, you want to run a query on the database which is along the lines of:
SELECT COUNT(userName) FROM myTable WHERE userName='DoesThisExist' If it returns a non-zero value, then the username exists.
(By preference, make this a parametrized query, or you leave your database open to SQL Injection attack which can damage or destroy it)
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
The number of tiers doesn't matter.
|
|
|
|
|
Don't get so hung up on "3 tier" and stuff like that.
You have a very specific problem you are trying to solve so just focus on that alone.
What you need to do is run a query against your database to check if a value exists. That's it.
public bool UserNameExists( string username )
{
}
I wasn't, now I am, then I won't be anymore.
|
|
|
|
|
Hi,
I had been working on C, C++, VC++ technologies for many years. I want to start learning C# .Net. I have little knowledge about C#.Net. I want to know from where to start.
And also what is the difference between C#, .Net, ASP.Net, ADO.Net etc etc ..
Any good books OR Tutorials to start from.
Any suggestion is welcomed.
Regards,
Mbatra
|
|
|
|
|
The important thing is to find a book or course in your native language - this makes life a lot easier for you because you aren't also trying to translate English while you learn.
After that, the Addison Wesley, Wrox, and Apress books are generally pretty good - just read it from start to finish and do all the exercises to make sure you don't miss anything too fundamental. Just avoid any books with "in XXX days", "For Dummies" or multiple exclamation marks in teh title!
If you get an email telling you that you can catch Swine Flu from tinned pork then just delete it. It's Spam.
|
|
|
|
|
|
CLR via C# is my personal recommendation to learn indepth about the framework.
If you just want to start learning programming, any good book will help you.
|
|
|
|
|
How advisable to use Socket.Select() with infinite wait option?
Socket.Select(IListClientRead, null, null, -2);
I am using thread for Receiving Data using select method. On first connect it works fine, but when I reconnect, the Socket.Select statements blocks forever.
Suggest a good link as a programming reference for
C#, sockets, multithreading
|
|
|
|
|
Lots of suggestions here[^].
|
|
|
|
|
Or better yet, ditch your C# sockets and go here[^]
|
|
|
|
|
Suppose I have an array of n elements ( for example double or string) I want to display them in the console in 2 columns, having the same number of elements and keeping the order.
if my
string[] my = new string[]{"a","b","c","d","e"} I need to display
a d
b e
c
So first column a b c
second column d e
First and second column should be spaced
It is like a menu
Any smart idea?
|
|
|
|