|
|
|
|
How... odd. I am not getting this warning, although my public class definitely returns List<t>...
|
|
|
|
|
Wonders never cease. I had no idea the Code Analysis Tool for Managed Code was hidden there in Visual Studio.
Now I'm afraid to turn it on - the flurry of 'Don't's will surely set me back another week.
|
|
|
|
|
Never heard of that.
That article doesn't present any really compelling reasons why it should be followed.
And anyway it doesn't change the basic question.
Now to go review my code and see where I violate that rule...
|
|
|
|
|
It really depends on what you need to do. If you need to add custom behavior, then you do need to write your own collection. However, even by writing your own collection you can still derive from one of the generic collections. Also, the recommendation is to only use the List<T> class internally; instead you should return a Collection<T> or a ReadOnlyCollection (which you can get from List<T>.AsReadOnly).
|
|
|
|
|
I have a C# class, say PhoneControlX, which is compiled into one DLL and referenced by both managed .NET and Unmanaged COM client (C# Window form and VB6 respectively). Via COM Interop, PhoneControlX implements IPhoneControlX and IPhoneControlXEvents to expose a couple of methods and one event, CauseCallOffered, to VB6 event sink. The C# Window form invokes methods and receive the event without any problem, while the VB6 works fine on method invocation only but fails on event sinking.
Specifically, PhoneControlX registers itself to PhoneControlServer, a remote object gotten via Activator. When a call comes in, PhoneControlServer will invoke CauseCallback to fire the event, PhoneControlCallback and hence PhoneControlCallbackEventHandler. However, when the client is VB6, PhoneControlCallbackEventHandler is never invoked.
Part of the code is as follows:
===============================
[ClassInterface(ClassInterfaceType.None)]
[ComSourceInterfaces( typeof(IPhoneControlXEvents) )]
public class PhoneControlX : MarshalByRefObject, IPhoneControlX
{
public event PhoneControlXEventHandler OnCallOffered;
...
public bool Connect()
{
BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();
BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();
serverProvider.TypeFilterLevel = TypeFilterLevel.Full;
IDictionary props = new Hashtable();
props["name"] = "RemotingClient";
props["port"] = 0;
_HttpChannel = new HttpChannel(props, clientProvider, serverProvider);
ChannelServices.RegisterChannel(_HttpChannel);
_PhoneControlServer = (IPhoneControlServer) Activator.GetObject(typeof IPhoneControlServer),remotingURI);
_PhoneControlServer.RegisterCallback(this);
}
public void PhoneControlCallbackEventHandler(object sender, IPhoneControlEventArgs e)
{
PhoneControlXEventHandler xe = new PhoneControlXEventHandler(CauseCallOffered);
AsyncCallback acbCauseCallOfferedComplete = new AsyncCallback(CauseCallOfferedComplete);
xe.BeginInvoke(e,acbCauseCallOfferedComplete,PhoneControlOperation.CallOffered);
}
}
public class PhoneControlServer : MarshalByRefObject, IPhoneControlServer
{
public event PhoneControlEventHandler PhoneControlCallback;
...
public void RegisterCallback(IPhoneControlX x)
{
this.PhoneControlCallback += new PhoneControlEventHandler(x.PhoneControlCallbackEventHandler);
}
...
public void CauseCallback(IPhoneControlEventArgs e)
{
if(this.PhoneControlCallback != null)
PhoneControlCallback(this,e);
}
}
I've worked on this problem for almost one week.
Any hints, directions or help is highly appreciated.
modified on Saturday, December 22, 2007 3:13:18 PM
|
|
|
|
|
hi there,
i wanna know that how can i make sub properties in a property(something like this)??
for example:
we can see padding property have 5 sub properties(ALL, Left, Right, Bottom....)
and second question is how can i define the category of the property which i made(shows when categorized)?
third is, how can i write desciption that show at bottom when i click on that property?
thanks
Becoming Programmer...
|
|
|
|
|
1 - the way to do this is for your padding property to be a struct. The 'sub properties' are actually properties on the struct.
2 - Not sure, I know you can do it, but I'd only be googling for you, I don't use that stuff, so I don't know.
3 - If you type /// above a property, the IDE will fill out the shell of a comment, that's where that text comes from.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
The first sounds like you want an enum .
The second is "Attributes".
The third was answered already.
|
|
|
|
|
1. You can use a class or struct. But you will need to make your own TypeEditor if you want to change the value on IDE/Designer and persist i the InitializeComponent part, aka WinForm designing. Search Code Project for an article on this.
2. If you mean showed in property grid, I believe it's in System.ComponentModel.Category. Just add it before the public property defination.
3. Same, it's in System.ComponentMode.Description.
Sorry didn't have my work computer so it's all from my memory :p
A sample from an article here.[^]
|
|
|
|
|
thank you very much, thanks to others too
Becoming Programmer...
modified on Sunday, December 23, 2007 12:08:31 AM
|
|
|
|
|
|
darkelv wrote: Or you can have your own UI editor
http://www.codeproject.com/KB/cs/propertyeditor.aspx[^]
thanks so much, it have all which i required
Becoming Programmer...
|
|
|
|
|
hi
how to format numbers of my app to arabic with NumberFormatInfo class?
thanks
|
|
|
|
|
Has google turned up any examples?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
|
Hi,
I have a problem with Crystal report and I don't know if I am in the correct forum but
this is my problem :
How Can I add a runtime value to the report?
I mean I want to create a page for print and I want to put the entered data into the report.
or after the data is added to the DB , how can i read that ?
PLEASE HELP ME
|
|
|
|
|
Not sure. You might want to look around on CR specific forums
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
how can I use this code (sp_attach_db and sp_detach_db ) for running my programme in another pc ?
|
|
|
|
|
these are sql functions, you need to install sql in that pc to run your application
Becoming Programmer...
|
|
|
|
|
Read documentation on them. They are SQL stored procedures...
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi gurus,
In an app. I need to have a Multiview control, like ASP.NET Multiview, to show different set of controls at a time to the end-user. As far as I know there is not such a control in .NET for WinForm apps. I also tried to hide TabbedControl's tabs and hide/show pages via code but I did not manage to do it.
Can anyone help me how to solve this problem out?
Thanks
Aref
|
|
|
|
|
Hi there,
I'd really appreciate any insight on the following problem:
I have a Luminary Cortex-M3 development board on a USB port. Luminary drivers offer a COM (COM15) port over USB and my board is writing to the port, 115200-8N1. Using a terminal program I do get the text from the board. When trying to write a C# program to read the data, I either het \0's or nothing at all. Writing to the board works fine. Environment is Microsoft Visual C# 2008 Express Edition and .NET Framework 3.5 on Vista Home Premium.
The code is as follows:
using System.IO.Ports;<br />
...<br />
private SerialPort port = null;<br />
...<br />
port = new SerialPort("COM15", 115200, Parity.None, 8, StopBits.One);<br />
port.Open();<br />
bool stop=false;<br />
while(!stop){<br />
while (port.BytesToRead>0)<br />
{<br />
int c=port.ReadByte();
}<br />
}<br />
...
Any idea what's going wrong? And please note that writing to the board succeeds and receiving data with a terminal program succeeds ?
Thanks in advance
Cheers
Matti
|
|
|
|