|
int len = mystring.Length > 200? 200: mystring.Length;
string temp = String.Concat(mystring.SubString(0, len), "...");
______________________________
The Tao gave birth to machine language.
Machine language gave birth to the assembler.
The assembler gave birth to ten thousand languages.
Each language has its purpose, however humble.
Each language expresses the Yin and Yang of software.
Each language has its place within the Tao.
Beauty exists because we give a name to C#.
Bad exists because we give a name to COBOL.
|
|
|
|
|
I am building a "generic" web service testing app in c#. The way I have it working now is I add the Web Reference in the IDE and compile. The prog will go type discovering for any class that inherits System.Web.Services.Protocols.SoapHttpClientProtocol in the assemblies of the current domain. It then lists out the methods and associated params available in that class. It will also get the definition for all the classes the respective namespaces of the WS classes and provide an "editor/viewer" of those complex types to either view return values of method calls or create instances of those complex types for use as input parameters to the web method.
What I would like is for my app to be able to:
- call wsdl to generate the .cs for for the web sevice (already done and working)
- call csc to compile it into a library (already done and working)
- Load the dll in the current assembly so that it "typed discovered" and instinciated. (type discovering works but instinciation raises a TargetInvokationException)
I get the dll as a byte[] and then load it with AppDomain.CurrentDomain.Load(rawAssembly). The assembly load correctly, the types are browseable but I can't instinciate them.
Thanks for your time, Louis.
My witty signature.
|
|
|
|
|
There was a recent article in MSDN that covers the two alternatives and how to use them. See Code Generation in the .NET Framework Using XML Schema[^]. It also discusses building types from WSDL - which of course you compile into an assembly - though it leaves much of the implementation to the reader. The basics are discussed.
If you're new to building assemblies (building types and filling in IL, aka "Reflection emit") or using the CodeDom, read Emitting Dynamic Assemblies[^] and Generating and Compiling Source Code Dynamically in Multiple Languages[^].
Why do you need to build an assembly to dynamically invoke methods on an XML web service, though? The classes already support configuring a class and you can always use HttpSimpleClientProtocol.Invoke to invoke methods (and properties, since they're just getter and/or setter methods). See the System.Web.Services.Discovery namespace documentation in the .NET Framework SDK for more information about classes and methods which help you discover information at runtime that you can use to "build" and invoke methods on the XML Web Service without having to compile an assembly at all.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
The reason I wanted to go with a compile approach is that I am more familliar with type discovery than I am with code generation using XSD. The main reason why I compile the assembly is go get the definition of the complex types to provide the user with an editor and so, I need the definition of the classes. I got that from the Type definition. Also, I use the Parse function of ValueType types to easily convert from a string to the actual type. I will look into using the type builder from xsd and then use them in the call to HttpSimpleClientProtocol.Invoke if need be. It would have been nice though to consume a DLL that is build for you by .NET SDK tools instead of parsing the WSDL and build the types in code.
Thanks, Louis.
|
|
|
|
|
Instead of using Parse , use the TypeConverter . Often, the TypeConverter for a particular Type will use a Parse method if it exists, but using a TypeConverter (which you can get using TypeDescriptor.GetConverter ) is abstract.
Also, what I mentioned before is that the classes in the .NET FCL already do the discovery for you, providing method names along with their parameters. Than all you have to do is use Invoke . Generate a source file for an XML Web Service in VS.NET, for example. Then show hidden files in your project and look at the source code. You'll see this is all the source code contains.
Compiling and loading assembly has further overhead because not only is it unnecessary, but you can't unload an assembly from your AppDomain . So, if someone uses your application for a while with many different web services, the machine will be at a loss for memory and - even with proper disposing and garbage collection (though you should rarely force it) - your application will grind the system to a halt (or slow enough that users may think the machine has froze).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you for the TypeConverter tip. I will change my prog to use the approach you pointed out (instead of generating code then Frankenstein on to my running program). It is a much better/.NETy approach than what I was going for. Thank you for taking the time to point me in the right direction.
Thanks, Louis.
|
|
|
|
|
There is no namespace called Microsoft.Win32.Interop. Instead just use Microsoft.Win32.
-Pete
|
|
|
|
|
Hiya
How do I get a full list of the assemblies stored in the GAC and their assembly info?? I can get an assembly info using LoadFrom().
Some code would be most helpful.
Thanks.
|
|
|
|
|
Try here[^] for a start...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi everybody,
I have created a custom user control(#1). It has textboxes on it. But these textboxes are custom user controls(#2) too. Input to those textboxes can be masked (string,number or character). I set tooltips on these textboxes. When I put my user control(#1) to a form tooltips can be shown. But on one form tooltips could not be seen on run time(At design time it can be show). I could not find anything about the reason. Can anybody help me?
|
|
|
|
|
Please advice best TreeList controls for .NET ?
I need to choose what to buy.
DevExpress suite -to compare with.
What is else best graphical suites there are on market for .NET ?
Thanks.
What is the best from that : ?
http://www.componentsource.com/Catalog.asp?fl=&gf=+BUSFUNCLISTCO&gd=Treeview+and+List&bc=&sc=CS
|
|
|
|
|
I've always liked XtraTreeList from Developer Express, which you mentioned. You already have a list it seems of tree views. What's best is what fits your requirements for the cost you're willing to pay.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
It is better to pay twice if abilities of control is twice,
due to next work will be too easy with same control,
but not new one need with new learning curve,
and new curve to conect them and loose consistency.
Need good control for most basic functions and most
need in advanced programing.
|
|
|
|
|
Not if you won't use those extra features. The Developer Express XtraTreeList is a very extensible control, as are most third-party controls on the market. The best way to determine which is best is to download the trials (they all have them) and try them out. Again, it comes down to whether or not a component fulfills your requirements that determines whether it's a good component. Only you can answer that question.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks you for qualified respond.
This control lookinsatisfying our basic requirements,
but task - is to satisfy best, most usual features,
to enchance controls, in the future..
That is about experience who used this controls,
or know something.
This control is
Best - strategy for productivity in the future in common ?
|
|
|
|
|
I have a combobox populated from a DataTable setting the DispalyMember and Value member properties. I want to set the selectedText to a text value i get from a table in a database which is one of the values of my Displaymembers in the comboBox?
|
|
|
|
|
Programmatically set it. After setting your data source and binding your control, you can set the SelectedIndex to 0 or whatever index you want (based on where your would-be text is stored in the DataTable ). This also depends on the DropDownStyle for the ComboBox . For the default - ComboBoxStyle.DropDown - SelectedText is only text that is selected - it does not necessary represent text in the ComboBox as an item. For example, if you typed some arbitrary text in your ComboBox and selected it, that would be the SelectedText . If you only want choices available to the user that are in your DataTable , then you should set ComboBox.DropDownStyle to ComboBoxStyle.DropDownList .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
thanks for the reply very useful as i was wondering whate the difference between selected text and selected item. I finally solved my problem by using the find FindExactText method for my dropdown list.
|
|
|
|
|
If you were wondering what the difference was, you should've read the property documentation for ComboBox.SelectedItem and ComboBox.SelectedText in the .NET Framework SDK.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Dear All,
I'm newer to C#. Now I plan to write a program to export dataset to excel file. I found that I could export the data cell by cell. But it is not efficient and the exporting progress is very slow because my data is huge.So I want to know if there is other efficient way to do so. Thanks.
Sincerely,
Jim
|
|
|
|
|
You might want to check this[^] article on MSDN. I think your best bet IS you go through and add each cell through code.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for your reply. I follow the step and use writexml method to export dataset to xml file.But unfortunately my data are too huge.So when I open the xml file, it waste me about one hour to complete opening the file by Excel.Could you tell me another way to expoert?Thanks.
Sincerely,
Jim
|
|
|
|
|
I just did! And it didn't have anything to do with XML!
Read my previous post, and click on the link. You'll find the code to do what you want. If you really want to compare methods for speed here[^] is another document that covers a number of different methods for getting data into Excel. But, using the Automation method is the most direct, so it's going to be the fastest, no matter which file method you choose...
If you have this huge amount of data (I hope it FITS into an Excel sheet!), why would you want to read this data from a file, reformat it and write it back out, then have Excel read it again? Seems like your doing 3x the file work compared to reading the data once and parsing and plugging the data directly into the worksheet.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Thanks for your reply again. In my situation I have to transfer the data out from SQL server,but the users in my office don't understand the SQL syntax.They only want to deal with excel file.So I have to write a program to faciliate thier work and export the data to excel.However, thanks for your replay and it really helps me lots.
Sincerely,
JIm
|
|
|
|
|
Hi,
I need to highlight the ListViewItem during dragOver operation. Since C# does not seem to be support this feature, I am acheiving the same by changing the BackColor and ForeColor as follows:
if (highlight){
listViewItem.SubItems[0].BackColor = Color.Navy;
listViewItem.SubItems[0].ForeColor = Color.White;
}
else {
listViewItem.SubItems[0].BackColor = Color.White;
listViewItem.SubItems[0].ForeColor = Color.Black;
}
This causes the entire listView to refresh making it look very ugly. I tried to control the refresh by invalidating only the listViewItem as follows.
listView.Invalidate(listViewItem.GetBounds(ItemBoundsPortion.Label));
But this too did not help. Also, the listViewItem is getting higlighted more than the Text area. It seems to be higlighting the Column's width.
Any thoughts on how I can acheive the highlighting in a better fashion?
Thanks.
Kiran
|
|
|
|