|
I wanna do something like
Dictionary<string, object=""> params = new Dictionary<string, object="">
string[] a = new string[10];
params.Add("Array",a);
CallWcfService(a);
It throws an error saying
Type 'System.String[]' with data contract name 'ArrayOfstring:http://schemas.microsoft.com/2003/10/Serialization/Arrays' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.
Any help?
- Projjal
|
|
|
|
|
Erhm, using .NET Framework 2.0 using a dictionary would look something like this :
<br />
Dictionary<string, string> myDict = new Dictionary<string, string>();<br />
myDict.Add("stringvalue", "stringvalue");<br />
|
|
|
|
|
I am reading strong name signing in .NET world. say I am developing dlls to distribute,
example1.dll I will get a strongname file using sn -k example1.snk, test example1.dll using its public key and sign it with private key when ready to release.
When I work on the second dll, example2.dll I will do the same thing - example2.snk, am I right that the private keys are different? Does it make sense in te same comapny,the private key should be kept the same(and secret) and the public keys change? Is there anyway to retrieve a private key from a .snk file?
Thanks
|
|
|
|
|
The strong name key used only really matters in a few instances. It can be used to set up a new category for security settings, so that assemblies from a given manufacturer can be given higher than normal privileges (e.g. to allow access to local files by name if running from a network drive). It must also be used in building Publisher Policy assemblies used to force clients of old versions of an assembly to a newer version of the assembly - this is to ensure that only the original publisher can do this.
The strong naming keys are a pair - one public key corresponds to one private key and no other. In general, one organization should use the same strong naming key for all applications. In some cases, you may want to reserve the private key for a final release step, to protect it from being accidentally used or used maliciously. In this case, use sn -p to extract the public key and save it to a separate file. Distribute the public key to your developers and secure the original key file which contains both keys. Developers then use the /delaysign option so that the compiler leaves space for the signature in the file, and records the full name of the assembly. They will need to use sn -Vr to suppress verification for that assembly or public key token, otherwise the Framework will refuse to load the assembly. You then need to use sn -R to re-sign the assembly, using the private key, for distribution.
However, BY FAR the simplest approach is NOT to use strong naming and simply make private copies of shared assemblies in each application which uses them. The GAC is overused, in my opinion - only those assemblies which really must be shared should go in the GAC. If you're not intending to place the assembly in the GAC you should not strong-name the assembly, because the Framework uses different location rules for strong-named versus private assemblies.
|
|
|
|
|
In one connection i want to take two sqlcommands cmd1 and cmd2 is it possible ??????????????
srinivas
|
|
|
|
|
hi,
yes...............
you can do it...............
nisar inamdar
|
|
|
|
|
It depends on your database, .NET Framework version, and connection string.
In any version of SQL Server and .NET Framework, you can execute as many commands as you like on one connection, as long as you close the first data reader before opening the next one. In SQL Server 2000, and .NET Framework 1.1 connecting to SQL Server 2005, you cannot execute any commands when you have a SqlDataReader open on the same connection. If using .NET Framework 2.0 with SQL Server 2005, you can use a new feature called Multiple Active Result Sets (MARS). The connection string option to control this is called MultipleActiveResultSets. It's enabled by default, but it does use more resources on the server.
If you execute commands on different connections, SQL Server will consider them as commands from different clients and you can end up blocking or deadlocking your own code.
It's generally recommended to keep connections open for the minimum time possible - the length of a transaction, which is recommended to be short. If connection pooling is turned on (as it is by default) you will normally still get back a connection object that is still actually connected to the server, so you don't pay the cost of connecting to the server again.
|
|
|
|
|
Hi
I have one rdlc report. It has one text field and one datafield.
I want to show both in report viewer but when I print this report only datafield print .....
Please replay as soon as posible...
Thanks in advance...........
hi...
|
|
|
|
|
Hi All,
I'm after a little guidance regarding SQL database access in C#.
I come from a VB6 background and rightly or wrongly the way i was shown database access with ADO was to open a global connection at the beginning, use it throughout the program and close it down at the end or if a problem occurred.
I understand now that keeping a connection open for the whole time is wrong but i would like to understand what the correct way in C# is.
At the moment i have created a single static connection in a static class and i've set the ConnectionString property at the very beginning though i don't open the connection. Then throughout the program i open the connection, perform the work and then close it afterwards.
Now, should i be doing it this way or should i be creating a new connection at every point where database access is required ? I take it that as long as the ConnectionString remains unchanged (Maybe using a static string to hold the connectionstring), a connection will be taken from the pool??
Is there a preferred or 'Best Practice' way of accessing a database throughout a program?
Thanks in advance.
Matt.
|
|
|
|
|
matbuk wrote: I understand now that keeping a connection open for the whole time is wrong but i would like to understand what the correct way in C# is.
In .NET, not just C#, the guidelines suggest that you open a connection, perform your query and then close the connection. If you have multiple queries to perform in quick succession then you may keep the connection open for those queries.
.NET implements connection pooling so there is negligible performance hit after the connection is opened for the first time. Just ensure that each time you open a connection you use the exact same connection string.
matbuk wrote: Then throughout the program i open the connection, perform the work and then close it afterwards.
Sounds good to me.
matbuk wrote: Now, should i be doing it this way or should i be creating a new connection at every point where database access is required ? I take it that as long as the ConnectionString remains unchanged (Maybe using a static string to hold the connectionstring), a connection will be taken from the pool??
I, personally, use new connection objects but keep the connection string the same.
matbuk wrote: Is there a preferred or 'Best Practice' way of accessing a database throughout a program?
Create a DAL through which you access your database. Don't put database code in the presentation layer.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
Ready to Give up - Your help will be much appreciated.
My website
|
|
|
|
|
Thanks for your very quick response, i have a couple more questions if i may.
If i create a DAL class would i then create an new instance at every point where data access was required? Secondly, if i returned something like a DataSet from the DAL, whould the connection remain open?
Thanks,
Matt.
|
|
|
|
|
matbuk wrote: If i create a DAL class would i then create an new instance at every point where data access was required?
I typically make my DAL classes singletons. It gets created on the first use and then reused throughout.
matbuk wrote: Secondly, if i returned something like a DataSet from the DAL, whould the connection remain open?
DataSets are not connected to the database. So you can safely close the connection once you have the data and return a dataset.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
Ready to Give up - Your help will be much appreciated.
My website
|
|
|
|
|
Excellent. Thanks for your help.
I found this, is this a good place to start?
http://www.codeproject.com/cs/database/SqlWrapper.asp
|
|
|
|
|
Hello,
Does anyone know how can i generate the code to copy one class to another ? the class is not seralizable.
I was thinking implmenting it by recursive reflection that would generate a code (I don't want to use refelction due performance).
Did anyone already implmented it ?
Thanks,
|
|
|
|
|
Hello,
I think implementing IClonable would help you!
Look at this article[^] from Amir Harel.
All the best,
Martin
|
|
|
|
|
I'm drawing Video on a Panel Object using AudioVideoPlayback Class. Now I'd like to put some text (or Image) on it. Any Ideas on how to do that???
Thanks...
|
|
|
|
|
Erhm, do you want to place the text in the video file, or do you just want to render the text over the video when playing ?
|
|
|
|
|
Hi.
I have some classes which I want to serialize to XML Documents.
If there is a field/property in an object of such type and it has a null value, when I serialize the object, the corresponding XML Node is omitted, so it doesn't appear at all in the output document.
Is there a way(I'm thinking maybe a Serialization attribute) to change this behavior so that in the generated XML document, the node appears with an empty value?
Thanks.
|
|
|
|
|
blackjack2150 wrote: he generated XML document, the node appears with an empty value
In the case of a string, How would it distringusish between empty and null?
<XmlNode attribute=""> - here "attribute" is empty
<XmlNode> - here "attribute" is null.
No way around that unless you want to make your value empty rather than null!
|
|
|
|
|
Thanks for the interest.
But it's not about attributes. It's about the value itself.
Let me give you an example:
Say I have the simple class:
class Human
{
public string name;
public int age;
public int height;
public char gender;
}
If I declare a "Human" variable and give values to some of the fields, but not all:
Human John = new Human();
John.name = "John Stevens";
John.age = 23;
I don't give any value to the height and gender fields.
After that I serialize this class to XML.
The output will be:
<xml...>
<Human>
<name>John Stevens</name>
<age>23</age>
</Human>
You notice that there are no tags for height and gender because these values were not initialized.
Bottom line:
Is there a way to get this output xml for the same chain of events as described above?
<xml...>
<Human>
<name>John Stevens</name>
<age>23</age>
<height />
<gender />
</Human>
Thanks.
|
|
|
|
|
Hello all,
I've created a setup project in visual studio 2005 in c#.
When I run the setup.exe to installation folder step, I realized that it installed some other data in system driver-usually drive c (press the Disk Cost button) even if I installed the application in other drive (let's say drive d).
Does anyone knows what's this data?
this data is 1.2 Mb..
RoyRose.
|
|
|
|
|
RoyRose78 wrote: Does anyone knows what's this data?
I don't know. But I do know how to find out: Find some sort of file monitoring tool (sysinternals might be a good place to start) and watch what it is writing to disk.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
Ready to Give up - Your help will be much appreciated.
My website
|
|
|
|
|
I have one RDLC report and it has many value fields(Data fields).
I want to print only this data values but see all report in reportviewer .
Like billing system ......
simplly i have two name see reportviewer but print only one name....
Thanks in advance....
hi...
|
|
|
|
|
Hi,
i'm new in using Crystal Report Viewer..i want to ask how can we bind our data so it can appear in the Crystal Report Viewer, for example: i have a database name Contact and a table name User..what i dont know is bind the data inside table User and view it in our CrystalReportViewer.Please Help me..i use sqlserver2005 for the database
Thank You
Regard,
TCim
|
|
|
|
|
Hi,
I'm a beginer in this language and i hope that there is someone out there who can help me
I want to create a form that has 2 areas. One area is where all the pre-drawn shape is located and the other area allows the shapes to be drag and drop onto it. Any tips what i should do and what kind of classes that i should use?
Thanks
|
|
|
|