|
Hi,
I'm using NetworkStream to sending and receiving data.
The problem is that I'm sending very fast arrays of bytes (size 20000) and i'm receiving some thrashes(I mean the arrays that i didn't send).
Has anyone had this problem?
|
|
|
|
|
hi all !
how can i send sms and recieved sms via using c#.
plz help me.
thanks a lot ,
s_mostafa_h
|
|
|
|
|
|
I'm able to retrieve embedded resources like Bitmap s and String s using the properties that Visual Studio 2005 adds to Resources.Designer.cs (or using the ResourceManager in that same file). But for some reason I have not succeeded in doing the same with a Cursor . Visual Studio only accepts a cursor as a file, thus giving me a byte array instead of a Cursor object.
Of course I can do it the "old-fashioned" way, like this:
System.Reflection.Assembly MyAssembly = System.Reflection.Assembly.GetExecutingAssembly();<br />
Cursor MyCursor = new Cursor(MyAssembly.GetManifestResourceStream("MyProject.MyCursor.cur"));
But still, I would prefer it I could treat cursor the same other resource types.
Am I missing something or is this simply an ommision on the part the Visual Studio crew?
Speaking of cursors, why does C# only seems to support monochrome cursors?
|
|
|
|
|
jjansen wrote: Speaking of cursors, why does C# only seems to support monochrome cursors?
Well the framework is simply dumb at this point. Its even mentioned in the documentation of the Cursor class that only not animated monochrome cursors are supported.
|
|
|
|
|
I had hoped C# 2.0 would have corrected this shortcoming. I really miss that colourful swimming jellyfish from Windows95
|
|
|
|
|
In my Embedded Image Grabber[^] tool, I managed to pull cursors out of embedded resources. I think that I did a byte-for-byte copy into a file and then loaded that, or something...
The source code is available in the article.
Josh
|
|
|
|
|
Josh Smith wrote: In my Embedded Image Grabber[^] tool, I managed to pull cursors out of embedded resources.
It would appear you're using the same method as I currently am, ie. by getting a manifest resource stream from the assembly. Effective, but not as "fancy" as through the Resources property .
|
|
|
|
|
Oops...I guess I should have read your post more thoroughly.
|
|
|
|
|
Hello,
I'm attempting to use a factory pattern for the first time and I've hit an obstacle. Can Anyone assist?
I have 2 classes, ClassA and classB.
The 2 classes both implement an interface called 'notifier'.
This interface has one method called 'notify'
Class A contains other methods as well as the 'notify' method.
Class B contains only the 'notify' interface method.
What I am attempting to do is call a factory method that will create and return a new instance of either classA or classB, dependant upon a type parameter that is passed to the method.
Can anyone tell me the correct way (pseudo syntax?) to implement this?
Thanks in advance!
|
|
|
|
|
Hi,
assuming both classes have an empty public constructor the following would be one possible solution:
public IMyInterface CreateMyInterfaceClass(Type type) {
return (IMyInterface)type.GetConstructor(new Type[0]).Invoke(new object[0]);
}
|
|
|
|
|
Robert,
Thanks for the response, but I think I probablt didn't explain it too well. The type parameter that I pass to the method isn't an actual insatnce of a type. It's a value that I can use within the method to determine which type I need to return.
|
|
|
|
|
What type of value is it. An enumeration? If yes I'll make another guess:
public enum MyEnum {
ImplA,
ImplB
}
public IMyInterface CreateMyInterfaceClass(MyEnum type) {
switch (type) {
case MyEnum.ImplA:
return new MyInterfaceImplA();
case MyEnum.ImplB:
return new MyInterfaceImplB();
default:
throw new ArgumentException("type");
}
}
|
|
|
|
|
Robert,
Thanks again - I think that will work perfectly. Can I just ask one further question though? what type of variable declaration would I need to declare for the value returned from method CreateMyInterfaceClass?
The returned object will have one common method (i.e. notify) that I will need to call.
Thanks again in anticipation.
|
|
|
|
|
You should define an interface containing this method which both classes need to implement:
public interface IMyInterface {
void Notify();
}
public class MyInterfaceImplA : IMyInterface {
public void Notify() {
}
public class MyInterfaceImplB : IMyInterface {
public void Notify() {
}
In this case the method should return (like in my example) the type IMyInterface. Which one of your both implementations gets called later on is then only dependant on which implementation your factory returned.
|
|
|
|
|
Robert,
Thanks ever so much, - you've been a great help!
|
|
|
|
|
The type of the return value from the method should be the interface.
interface INotifier {
...
}
public static INotifier CreateInstance(...) {
...
}
---
b { font-weight: normal; }
|
|
|
|
|
Return your instance of ClassA or ClassB polymorphically as an instance of IMyInterface. The whole point of the factory is to provide an instance (no matter what the implementation) of your interface.
Try code model generation tools at BoneSoft.com.
|
|
|
|
|
hi all,
how can i list running processes ?
howto start or terminate a process ?
is it possible to manage programs like msn or icq with c# ?
i want to be able to send or receive messages both from icq and msn via a program i code ? and change online / offline status of such programs ?
help please,
thanks in advance,
bye.
|
|
|
|
|
1. Process[] processes = Process.GetProcesses();
2. Process.Start(ProcessStartInfo processStartInfo);
3. If there are API for that program, then the answer yes. Search in codeproject or google.
4. See number 3.
5. See number 3.
|
|
|
|
|
1. To list all running processes
System.Diagnostics.Process[] procs=System.Diagnostics.Process.GetProcesses();
2. To terminate a specific process
procs[0].kill();
3. To manage MSN/ICQ
Of course you can do, but exacyly how, i dont know. But i certainly have seen such apps[ Don't know exactly if they were written in Dot Net or not. Even if they were not, they can be written in C#]
Regards,
Wasif Ehsan
Software Engineer
|
|
|
|
|
i am using c# to develope window based application
in my application i am adding and removing lables in pannel control during
runtime,but in between i am getting a error "cannot create windows handle".
can any one help out
regards
rahul
rahul
|
|
|
|
|
i made a share folder on the server with permission to a local user account not a domain account.
i can access the folder by impersonate domain account through LOGONUSER() function but it fails with the local user account.
how can i impersonate the local user?
the following links is valid for domain account only:
http://www.codeproject.com/useritems/User_Impersonation_in_Ne.asp[^]
yossef elnaggar
|
|
|
|
|
Please examine the following article and send your suggestion to improve the article
http://www.codeproject.com/useritems/SqlQueryInXml.asp
|
|
|
|
|
Suggestions
1) You may want to format your XML and C# code so it is propely indented. Also, removing commented out code is preferable before posting your article.
2) You should read up on "encapsulation" and "Data Abstraction Layers", your article tries both but achieves neither
3) Please dont plug your article in the forums
Current blacklist
svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour
|
|
|
|