|
thanks for answer. i am new in wcf so can u please give a small full example of wcf for my situation with sample code and config code to better understand.
tbhattacharjee
|
|
|
|
|
Basically in your web.config set the configSource for the bindings section so that you specify a different file for development and live.
Your development web.config
<bindings configSource="bindings.dev.config" />
Your deployed (live) web.config
<bindings configSource="bindings.live.config" />
That's it. This is not really related to WCF, as it's more related to understanding how to construct a web.config for different environments.
|
|
|
|
|
can you please redirect me to any similar kind of article which discuss everything in details with sample code. thanks
tbhattacharjee
|
|
|
|
|
Just change your web.config file as I have suggested and you should be fine.
Where you see this....
<bindings>
change it to this....
<bindings configSource="bindings.dev.config" />
Then you need to create a new file called bindings.dev.config that holds your bindings config values for development and bindings.live.config for your live config values.
So the steps are.
1. Amend your web config file and change the binding section as described above.
2. Create two new files called bindings.dev.config and bindings.live.config
3. In your development web.config specify the bindings.dev.config
4. In your live web.config specify the bindings.live.config
|
|
|
|
|
I am be an error importing the Excel2007: "Not a legal OleAut date", you see my code below:
[CODE]
public static void ImportToSql(string excelfilepath)
{
string ssqltable = "TABHD";
string myexceldataquery = "SELECT * FROM [dbo_TABHD]";
try
{
string sexcelconnectionstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source =" + excelfilepath + "; Extended Properties=\"Excel 12.0; HDR=Yes; IMEX=2\"";
string ssqlconnectionstring = @"server = itfriend;Database=HD;integrated security = true";
//execute a query to erase any previous data from our destination table
string sclearsql = "delete " + ssqltable;
//INSERTING IT.INSTEAD I WANT TO UPDATE TABLE DATA"
SqlConnection sqlconn = new SqlConnection(ssqlconnectionstring);
OleDbConnection oledbconn = new OleDbConnection(sexcelconnectionstring);
OleDbCommand oledbcmd = new OleDbCommand(myexceldataquery, oledbconn);
oledbconn.Open();
OleDbDataReader dr = oledbcmd.ExecuteReader();
SqlBulkCopy bulkcopy = new SqlBulkCopy(ssqlconnectionstring);
bulkcopy.DestinationTableName = ssqltable;
bulkcopy.WriteToServer(dr); // Eror in here: "Not a legal OleAut date"
Console.WriteLine(".xlsx file imported succssessfully into database.", bulkcopy.NotifyAfter);
oledbconn.Close();
}
catch (Exception ex)
{
//handle exception
MessageBox.Show(ex.Message.ToString(), "Warning !");
}
}
[/CODE]
|
|
|
|
|
|
1) i like to know what is binary Serialization and when people use binary Serialization ?
2) what is the default Serialization type?
3) how many type of Serialization exist?
4) what is basic difference between xml serialization & SOAP serialization ?
i will be happy if someone discuss all my points in details with patience. thanks
tbhattacharjee
|
|
|
|
|
You're not looking for a discussion, but answers.
1) Serialization is the process of converting an object into a stream of bits.
2) There is no default
3) There's binary, xml and soap in the framework, but more have been added by the community.
4) formatting.
MSDN - Serialization[^]
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
|
|
Hi,
I have Sage Peachtree 2012. I can see the API folder in C:\Program Files (x86)\Sage\Peachtree but there are no documentation available.
Anyone tried to work on the integration to read / write into Sage Peachtree with C#?
How to get started with it?
Thanks,
Jassim
Technology News @ www.JassimRahma.com
|
|
|
|
|
Googling using the following certainly seems to suggest that documentation can be found.
peachtree api documentation
|
|
|
|
|
OK, this may be a stupid question, but I am trying to write an utility method to convert an instance of a class to Dictionary<string, string> where the key being the property's name and the value being its value. I have already taken care of string and the primitive types and other types. The problem is with System.Array and collections.
What I am trying to achieve is, if I have an instance of a class having ICollection<string> MyProperty property with a few string values, the dictionary item for this property should be something like {MyProperty, {Val1,Val2,..}} i.e. comma separated values as the value for the dictionary item.
The method I have is:
private string GetValueForNonPrimitiveProperty(PropertyInfo property)
{
StringBuilder value = new StringBuilder();
if (property.PropertyType == typeof(string))
{
value.Append(property.GetValue(this));
}
else if (property.PropertyType.Namespace.Contains(CollectionsNamespace) || property.PropertyType.IsArray)
{
var collection = property.GetValue(this);
}
...
return value.ToString();
} is giving me proper value-collection in collection variable along with "appropriate" type but only at runtime (it's an object at compile-time). But since I only get to know the "actual" type of the collection (like List<string> , List<int> , etc, but List of only simple types), I am not sure how to iterate through those values.
I tried casting collection to List<object> hoping to then iterate over after casting, but the cast is returning a null .
Also, simply checking the property-type's namespace against "System.Collections" doesn't seem to be the proper way to check for a collection-type. Please suggest.
Any help would be greatly appreciated.
Whether I think I can, or think I can't, I am always bloody right!
modified 23-Sep-14 7:58am.
|
|
|
|
|
Just curious: are you actually trying handle instances of Classes that might have multi-dimensional Arrays, or generic Lists which contain other generic Lists, like: List<List<int>> ?
Is it possible you "off-load" the possibly complex parsing task by serializing the Class instance into XML, or JSON, and then read that back in, and parse that ?
Care to say why you are pursing this ?
« I had therefore to remove knowledge, in order to make room for belief » Immanuel Kant
|
|
|
|
|
No, there will only be collections of simple types (int, string, etc), as I see the classes. It's not entirely my code.
Whether I think I can, or think I can't, I am always bloody right!
|
|
|
|
|
Agent__007 wrote: there will only be collections of simple types (int, string, etc), That leaves me with the question of why this particular string format representation of the Class' content is what you want. What's wrong about the XML, or JSON result of serializing ?
In any case, good luck
« I had therefore to remove knowledge, in order to make room for belief » Immanuel Kant
|
|
|
|
|
BillWoodruff wrote: why this particular string format representation of the Class' content is what you want. As far as I am told, these values of collections (like Value1,Value2,..) will be passed to an API through its URI. I can't argue with them or even think much about it at the moment as I am working on 3 projects in parallel...
I have found a solution, please see the replies below. Thanks anyway.
And yeah, I indeed need a good luck! Thanks for that..
Whether I think I can, or think I can't, I am always bloody right!
|
|
|
|
|
I appreciate you were not offended by my question; I was planning to delete this (second) post, feeling like it kind of violates some kind of ethic I can't quite define ... "Thou shalt not Nag" ?
I post "speculative" questions on CP, and, this is the language discussion forum; may we all enjoy the freedom to explore the "outer limits," and, how excellent that, in many cases ... including this one ... the result is valuable, and educational !
cheers, Bill
« I had therefore to remove knowledge, in order to make room for belief » Immanuel Kant
|
|
|
|
|
Just out of curiosity, what is the final purpose of this exercise?
That said, you could try this code inside
else if (property.PropertyType.Namespace.Contains(CollectionsNamespace) || property.PropertyType.IsArray)
{
object[] values = (object[])property.GetValue(data, null);
if (values != null)
{
foreach (object o in values)
{
Type t = o.GetType();
}
}
}
|
|
|
|
|
Sorry, but the cast to object[] doesn't work. I have found a solution, please see Eddy Vluggen's answer below. Thanks anyway
Whether I think I can, or think I can't, I am always bloody right!
|
|
|
|
|
Hopefully this may be of some use.
List<int>; d = new List<int>() { 1, 2, 3, 4, 5, 6 };
if (typeof(IList).IsAssignableFrom(d.GetType()) == true && d.GetType().IsGenericType == true)
{
IList x = d;
Type t = x.GetType().GetGenericArguments()[0];
foreach (object item in x)
{
switch (t.Name)
{
case "Int32":
int r = (int)item;
break;
default:
break;
}
}
}
My only part I wasn't sure of was casting the object back to type that was in the list, So I used a simple switch statement to do the hard work for me. Also apologies for the crap variable naming too.
Every day, thousands of innocent plants are killed by vegetarians.
Help end the violence EAT BACON
|
|
|
|
|
Interesting! But I think I can simply cast the collection it to IEnumerable<object> and then simply .ToString() them in the final string, that should work, as I see the classes at the moment. Thank you very much!
Whether I think I can, or think I can't, I am always bloody right!
|
|
|
|
|
If it is an IEnumerable, then it can be iterated.
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
Told you that was a stupid question! But I wonder how I missed that.
Did a cast to IEnumerable<object> and it worked! Thank you very much!
Whether I think I can, or think I can't, I am always bloody right!
|
|
|
|
|
Hi Everyone .
how TCPServer can send file to client ??
but my question is i want to send file to client : but client is having some folder like Usr, Bin and etc.
but i want send file from server to client folder to "USR"
is it possible . if any knows please help me out
|
|
|
|