|
|
For some reason DataSource,DisplayMember, and ValueMember don't seem to be properties of the CheckedListBox control. I even created a new project, dragged an new CheckedListBox and looked in the properties and tried to type it into the code.
This is my first time using this particular control with C#. In VB it still pops up in the Intellisence.
What am I missing?
Robert L. Edwards
|
|
|
|
|
public bool BeginsAlpha(string strToCheck)
{
System.Text.RegularExpressions.Regex pattern = new Regex("^[a-zA-Z]*");
return pattern.IsMatch(strToCheck,0);
}
BeginsAlpha("1") returns true no matter if my string starts with a letter or a number. What am I doing wrong here?
|
|
|
|
|
* means "0 or more characters", so when you try to match against:
3djd
you successfully match zero alpha characters.
If you get rid of the *, you'll have to match 1 character, which I think is what you want.
|
|
|
|
|
thank you! with that in mind, i used a + instead of a * and it worked great!
|
|
|
|
|
Hi,
Im looking to create a client/server c# application. I've been reading many articles on the subject, but the developers always seem to be arguing about the best practices after the article.
I was just wondering if anyone has any tips? to use synchronous or asynchronous, etc. Polling or Events etc?
I need to support upto 10 clients.
I've created a client/server app with Java before where (for the server) I created a thread to listen for connections, when a connection was made it passed the socket to a clientservice class and ran it in a new thread, then saved a pointer to the class in a vector array. Is this the same approach I should take with c#?
Thanks in advance,
Matt.
|
|
|
|
|
The best way is to allow for both synchronous and asynchronous calls. One thing that CP articles typically miss is reusability and portability. It's always better to make your application scalable and extensible so that clients can use it however they want (those posing restrictions isn't always a bad thing) and you could even mix sync and async calls. Sometimes one is better than the other - it just depends upon the circumstance. That's the server.
The client is a slightly different matter. The server should be an extensible architecture that scales. The client must choose how to use the server. In the case of Web Services, async methods are generated automatically (if you want). If there is a process in which you want the user to wait and it can't / shouldn't be cancelled - use a sync call. If they can cancel it or you want to update the UI or something while waiting, use an async call.
Now, if you use remoting, you have some further options. Providing scalability is important, but your hardware is limited no matter how big you are. You could always support a certain number of async calls, but after so long the hardware gets sluggish. You could inform your client apps (using channels for example) to start using sync calls to cut-down on the server load.
Basically, everything you're reading is right and wrong. There is no "right" or "wrong" way for every circumstance, but there are "right" and "wrong" times to use different techniques.
I know this answer is a little abstract, but I hope is solves your dilema.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Thanks very much for the detailed reply Heath, I've taken note of many of your points, Generally I think I need to put time aside to study the networking features of .net to better understand the best solution for my requirements.
Thanks Again,
Rgds, Matt.
|
|
|
|
|
To echo what Heath said, it depends on what your client server application is like. Which way does the information flow? Who initiaties the information transfer? What kind of latency requirements do you have?
To speak in general terms, if your clients ask for data and get back a response, you can choose your technology. Remoting gives you rich types, but only works with .NET programs, while web services give you reach but less richness in the type area. Neither are particularly good when the server needs to tell the client something asynchronously, though you can get away with polling or blocking calls until a timeout or something interesting happens.
Sockets give you the most flexibility, but you'll probably be writing a bit more low-level code. I wrote some C# code recently that does what you describe using sockets, and implements a nice event-based approach. The client calls a method on a object, which sends a message to the server. This gets rebuilt into an object on the server, and an event on the server object is fired. Same thing when the value comes back to the client. This gives you more flexibility, but moves you into a message-based approach rather than the RPC idiom that web services and remoting use.
Hope that helps.
|
|
|
|
|
Hi Eric,
The basics of my application is that the server will have a central msde database, and the clients will connect to the server to perform any data related tasks. Thats the basics of it, it may become more complex as development proceeds.
Im planning to use c# to develop the application.
Thanks for your help, I'll keep your comments in mind.
Regards, Matt.
|
|
|
|
|
I have a similiar approach also.
Clients need to rapidly change data in a database.
My approach is this for schedules and things I use the data layer approach, then use reflection to populate classes.
I found that some of the extensive tasks done to the database could wait to be updated so I logged those into queued components for com+
I have external customers accessing web services which I have services linked to and I also manipulate those external web services along with fax reading/writing, auto mailers and tech data which I run as services on another server to give the db server full optimization.
In other words I decided to take what features were instantaeous and what could wait and set a time for them to be processed.
I think .NET remoting in combination with COM+ is great in that it closely mimics the J2EE environment. You operate in lifetime cycles rather than concrete data.
my 1/2 a penny
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Message Closed
modified 29-Jun-15 10:36am.
|
|
|
|
|
mithunshanbhag wrote:
A good software to generate this tier can be found at http://www.sd.nl/software/llblgen.asp. This layer would automatically generate the connectivity Classes, Database Connection String and The Stored Procedures for your database (i used it on SQL Server 2000. dunno if it works for MS Access.)
Uhh why?
I mean its really extra work when you think about it. Its not the teams coding style, you have to spend extra time learning the style and how the communication is designed. Especially if it creates a lot of classes. Really code generators are a wiast of effort in my opinion, for a midsized project they cause more hurdles than thier worth. What about when something changes, it takes more time to leartn the code than write it. These were expressed in an article on this site but I cant remember which one it was.
And really does it use reflection to populate and a connection string, thats as simple as dragging a DataConnection onto your form in the IDE. And stored procedures are nothing but easy. I can create 50 of em in one day.
But then again thats my opinion.
nick
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Message Closed
modified 29-Jun-15 10:35am.
|
|
|
|
|
Yeah I understand, I have been a consultant for far toom many IT managers who were not technical thinking this was great and called my aganecy for me to save the day.
I love development tools like advanced intellisense and what not but I am biased on eagerly against code producers.
I'm not an expert yet, but I play one at work. Yeah and here too.
|
|
|
|
|
Hello all,
I got this object obj, it's an instance of CTestClass. Now I want to pass this object across my network using MyWebService. So, I've wrote a Method called GoObject:
[WebMethod]<br />
[XmlInclude(typeof(CTestClass))]<br />
<br />
public bool GoObject(object obj)<br />
{<br />
if(obj is CTestClass)<br />
{<br />
return true;<br />
}<br />
<br />
return false;<br />
}
But, whenever I call this method passing a client side instance of CTestClass, I get the following error message:
The type TesteClass.CTestClass was not expected. Use the XmlInclude or SoapInclude attribute to specify types that are not known statically.
What's the professional way to perform what I'm trying to
Best Regards
Raphael Amorim Dantas Leite
VC++, Java and C# programmer. Win32 and PocketPC enviroments
|
|
|
|
|
As the error states, the WSDL for Web Service is missing a type declaration for the CTestClass. You either need to edit the WSDL manually, or better yet - do what the error tells you. Include the CTestClass type using either the XmlIncludeAttribute (better portability) or the SoapIncludeAttribute that take a Type as a parameter:
public class Test : WebService
{
[WebMethod]
[XmlInclude(typeof(CTestClass))]
public bool GenericUpdate(object o) { }
}
Otherwise, the web service doesn't understand know the WSDL for the CTestClass type and can't deserialize it. See the .NET Framework documentation for XmlIncludeAttribute for a good example.
PS: You shouldn't use the old Polish notation with classes and members in .NET, like beginning classes with a "C". Most languages have language guidelines that developers should follow when possible to make all libraries consistent and easy to use. There is a design guidelines in the .NET Framework that describes the changes (really not that bad and mostly for public/protected members), but they are good to follow.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
How do I edit the WSDL manually?
Raphael Amorim Dantas Leite
VC++, Java and C# programmer. Win32 and PocketPC enviroments
|
|
|
|
|
Short answer...don't! There's a lot of work involved (and you really have to understand WSDL) and ever time you compile with changes you'd either invalidate the WSDL or loose it. All you'd be doing, though, is adding a definition for the CTestClass , which is what using the simple one-liner XmlIncludeAttribute above the method would do. I strongly suggest using the latter route.
If, for some reason, you need to edit the WSDL directly I suggest you check-out some of the MSDN articles on Web Services. Several of them do this but they have enterprise-ready solutions that sometimes require more than the framework provides. From what I can tell, the XmlIncludeAttribute is exactly what you need (since ASP.NET will pull the type from the dependent assembly which must be there for the o is CTestClass statement to work anyway, into the WSDL generated for WS clients).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
So, Is something like this?
[WebMethod]
[XmlInclude(typeof(CTestClass))]
[XmlIncludeAttribute(typeof(CTestClass))]
public bool GoObject(object obj)
{
if(obj is CTestClass)
{
return true;
}
return true;
}
Raphael Amorim Dantas Leite
VC++, Java and C# programmer. Win32 and PocketPC enviroments
|
|
|
|
|
You actually have the XmlIncludeAttribute specified twice! Remember that languages like C#, VB.NET, and MC++ don't require the "Attribute" suffix, though some languages might (it depends on the compiler). Simply:
[WebMethod]
[XmlInclude(typeof(CTestClass))]
public bool GetObject(object obj)
{
if (obj is CTestClass) return true;
return true;
}
And make sure that the assembly in which CTestClass is defined is referenced as a dependent assembly (or in the Web Service assembly itself, although this doesn't make any sense since the client can't use the type (even if retyped, since a Type is defined by its namespace, class name, assembly name, and public key token).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
Hello, has anyone ever created a MIME filter before (c# or otherwise)?
I tried to make a mime filter for a content-type that I invented: "text/myml", and when I test it, my filter's Start() method get's called, but then nothing else happens. The behavior in the browser is that it just hangs until I click the stop button. Although, when I click the stop button, IE calls my mime filter's Abort and Terminate methods.
Is there something special my MIME filter has to do in the Start method? All I have it doing right now is store m_Sink and m_pIncomingProt.
Also when Start() is called, dwReserved.pProtocol comes in null. I don't know why but that seems like a bad thing?
"Outside of a dog, a book is Man’s best friend. And inside of a dog, it’s too dark to read."
-Groucho Marx
|
|
|
|
|
Do you have documentation source for this? I need to do something similar, and I assumed that it would require writing a COM server...
Arun
|
|
|
|
|
It does, and I haven't had much success doing so. You need to look into the IInternetProtocol interface and its related interface. You basically have to recreate a lot of that functionality in .NET. By the time you're done, you may as well have done it in C++ because of the amount of work.
I was working on a library for it (abstract class and stuff like that), but there's a lot of hang-ups because interface methods don't always interop using 1-to-1 parameter mapping. For instance, the IClassFactory.CreateInstance method is only supposed to take 2 methods (while the return type is still void) instead of 3. Just weird stuff like that.
If you want, you could create forward declarations of these in an IDL file, compile the IDL file using the MIDL compiler, then generate an interop assembly using tlbimp.exe. It works to generate the interfaces, structs, and enums, but it's very messy and doesn't always provide what you need. For instance, it always creates methods that return void , when some of those protocol methods must return an HRESULT (int or uint is good in .NET) in order to work correctly, since different return values tell the client to do different things. This becomes a big problem when generating the interop assembly automatically.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
I would like to be able to accept phone numbers in various formats:
800-555-1212
800.555.1212
(800) 555-1212
(800)555-1212
and then format it to this:
800-555-1212
i created a function which strips out characters: ()-<space>
so now my number is: 8005551212
but how can i put the "-" back in there to make it 800-555-1212 ?
thanks in advance!
|
|
|
|
|