|
|
can i use a custom attribute on a method to access and modify parameters and varibles inside a method?
overriding is not applicable in my case
thanks
Mahasen
|
|
|
|
|
ms-help://MS.VSCC.2003/MS.MSDNQTR.2004APR.1033/cpref/html/frlrfsystemattributeclasstopic.htm
This link in MSDN 2003 will help you
M.Sendilkumar
Senior Software Engineer
TVS Infotech
Chennai,TamilNadu,India.
98413 27002
|
|
|
|
|
Hello, I am a newbie in interoperability, and I met a problem with SAFEARRAY in inter-thread communication; unfortunately, I found nothing close to this problem on the Internet.
To summarize:
I have exposed .NET classes to COM clients, one of the classes has an array has returned method value. And in COM (C++) it seems that passing a SAFEARRAY of n "myObject" from a worker thread to a UI thread fails whereas passing n times a single "myObject" works perfectly.
I want to know if something must be done on the c# array which is exposed to COM to solve that.
For those who met this problem (or are courageous), here are the details:
In C#, I have 3 classes "MyObject1","MyObject2" and "MyObject3".
"MyObject1" has a method which returns an array of "MyObject2": public MyObject2[] getArray();
"MyObject2" has a method which returns an instance of "MyObject3": public MyObject3 getObject3();
"MyObject3" has several methods which returns its id, name...
Now, I expose this managed code in a dll to unmanaged code, C++, with .NET framework interop fonctionalities.
In C++, I get:
"MyObject1->getArray()" has a safearray of MyObject2 as returned value
"MyObject2->getObject3()" has MyObject3 as returned value
Great! My managed code is exposed to COM clients!
Now the bug:
In C++, I have 2 threads "UI" and "worker", both are COINIT_APARTMENTTHREADED.
1. I create an instance of "MyObject1" in the UI thread
2. I pass this object to a worker thread method through a queue list
3. In that worker thread method, I call "MyObject1->getArray()" and get the SAFEARRAY of "MyObject2" as returned value
4. I pass back that safearray to a method callback of the UI thread
5. In that UI callback, I want to iterate on the safearray: for each "MyObject2" of the array, I call "MyObject2->getObject3()", then a method of "MyObject3"
-> bug: whatever the method of "MyObject3" which is called, it fails: it seems that "MyObject3" has a problem.
I have made some extra tests:
1. Test1: I put COINIT_MULTITHREADED to UI AND worker: no problem. But this patch cannot be used.
2. Test2: if I do steps 2-to-5 in the worker thread (which means I iterate the safearray in the worker thread, and never go back in the UI): no problem
3. Test3: if I do steps 2-to-5 in the UI thread (which means I never go into worker): no problem
4. Test4:
At step 3, I iterate on the SAFEARRAY. For each "MyObject2" of the array, I pass it to an other callback of the UI. Then, in the UI, I call "MyObject2->getObject3()" and then any methods of "MyObject3", and it is working!
That means that passing a SAFEARRAY of n "MyObject2" from worker to UI fails when we want to retrieve objects from each "MyObject2", but passing n times a single "MyObject2" works perfectly.
I wonder if I have something to add to my C# code so the marshalling/unmarshalling of the array works between threads.
Renaud
|
|
|
|
|
Hi,
I'm trying to write a serial port communication in Windows CE.NET ,
but when i call the 'CreateFile' method of the Kernel32 i get an unidentified exception.
The problematic function is :
"m_hFile = CreateFile(port, (uint)((m_bRead?GENERIC_READ )|(m_bWrite?GENERIC_WRITE )), 0, 0, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, 0)"
And i send "COM1:" as the name of the port.
Does anybody know how to develope a .NET base class library for serial port
communication in Windows CE?
Thanks,
Shay.
|
|
|
|
|
Hi,
I am trying to create a browser that i can use to capture GET and POST requests in C# (.Net framework).
I use the Microsoft Web Browser component to do the same. I register events like NavigateComplete2, BeforeNavigate2 and DownloadComplete but none of them provide me with complete POST headers.
The "header" member just provides
Content-Type: application/x-www-form-urlencoded
and nothing else.
I do not wish to use the HTTPRequest class because i want to support SSL based connections also.
Can someone please give me pointers on how i can get all the header values for every POST request. If there are any event handlers i can use please let me know.
Any kind of help will be much appreciated.
Kind Regards,
Shanit.
|
|
|
|
|
What you need to implement is a packet sniffer. A packet sniffer, 'sniffs' all the data sent via a port from an ip address OR data SENT from an ip address.
However, since SSL encrypts the channel all you get is the encrypted data. A good example of this is Ethereal[^].
Read this article (from CP!) about more information on a C# Packet Sniffer.
Hope this helps!
~javier lozano
(blog || email)
|
|
|
|
|
Hi~
Lei wrote
"I have 2 forms, form1 contains a ListView. What I want to do is, when
clicking an item in the ListView, hide form1 and show form2. Code for
ListView's SelectedIndexChanged: { form2.Show(); this.Hide(); }. When I
click the item, form2 shows with form1's title and menu. I noticed that when mouse down, the SelectedIndexChanged event was triggered and bring form2 to front. But when mouse up, system redrawed the selected item and bring title and menu back to form1's. I tried to handle MouseDown and MouseUp event of ListView but they were never triggered. Now I used a tricky way to solve the problem: start a thread and use Control.Invoke to switch forms. It is not good, I think there must be a better solution. Thanks."
I am facing the same problem. Someone solve it with setting timer. However, is there any other way to solve it?
Thanks~
|
|
|
|
|
Hi
I have developed a PocketPC application - I have a Client that calls WebServices (uses .NET Compact Framework) and I have a Server that publishes the web services.
I want to make sure that the same Client application ports to SmartPhone.
What changes do I have to do to the Client Code, and to the WebServices code in the server? Would the same webservices work for both? If not, how does the server detect who is calling the web service - the PocketPC or the SmartPhone?
Please help
Thanks
|
|
|
|
|
Hi!
I am developing a mulititier application.
I created some value classes with custom attributes specification.And i have seperate query builder class.This query builder class will construct the query based on the valueobject.Internally the query builder using reflection
reads all propertie's name and custome attributes.Upto that there is no problem.If i try to fetch the value of a property then the runtime error will occurs.For fetching the value i am using PropertyInfo.GetValue method.
So please any on help me to resolve this problem..
Type type=Obj.GetType();
foreach(PropertyInfo f in type.GetProperties())
{
foreach(Attribute attr in Attribute.GetCustomAttributes(f))
{
if(attr.GetType()==typeof(DefaultValueAttribute))
{
str+=":"+f.Name+":"+((ColumnMappingAttribute)attr).Name;
str+=f.GetValue(null,null); --This line shows error
}
}
}
Please help me to solove the problem
M.Sendilkumar
Senior Software Engineer
TVS Infotech
Chennai,TamilNadu,India.
98413 27002
|
|
|
|
|
If you would have read teh documentation for PropertyInfo.GetValue
you would have seen that the first parameter to it is the
"The object whose property value will be returned.".
If you read the Remarks section there, it says
"Because static properties belong to the type, not individual objects, get static properties by passing a null reference (Nothing) as the object argument."
But since you're trying to retrieve a non-static property that line should look like this:
str+=f.GetValue(obj,null);
So next time instead of "Waiting for 2 days" try "Reading the documentation for 5 minutes"
|
|
|
|
|
HI Roman Rodov
Thanks for direct me to have a correct solutions.I tried it, it is working fine.
M.Sendilkumar
Senior Software Engineer
TVS Infotech
Chennai,TamilNadu,India.
98413 27002
|
|
|
|
|
Hi
I creat new thread and run it:
System.Threading.ThreadStart st = new ThreadStart(MyRunig);<br />
tr = new Thread(st);<br />
tr.Name = "MyThread";<br />
tr.Start();<br />
at MyRunig :<br />
System.Windows.Forms.Application.Run();
so I have the new thread with window Q.
How can I send message from the main Thread (GUI) to the new one?
I am looking for Event driven mechanism
I used:
public void SendMyMessage()<br />
{ <br />
PostThreadMessage(fr.Handle,1122,(System.IntPtr)0,(System.IntPtr)0);<br />
} this is the way to send message?
<br />
[DllImport("User32.dll")]<br />
public static extern bool PostThreadMessage( System.IntPtr idThread, int msgID,System.IntPtr pm,System.IntPtr lm);
But I didn't get the message ( with WndProc )
Thanks
Koby
|
|
|
|
|
If you want to call functions on controls belonging to the other thread then you have to define a delegate for each of these functions (for each different method signature at least) and then use Invoke() or BeginInvoke() with these delegates.
Take a look at Control's members for a description of these tunctions.
mav
|
|
|
|
|
Anyone know of an easy way to input dates in the CF platform?
I have a form with a few text edit fields.
The users will probably fudge it up and try wrong formats, etc.
All I can see for now, is breaking up the text, and using "new DateTime(y, m, d)"
Thanks.
"For all of our languages, we cannot communicate" - Christy Moore, Natives
|
|
|
|
|
I've found the answer:
DateTime.Parse
DateTime.ParseExact
"For all of our languages, we cannot communicate" - Christy Moore, Natives
|
|
|
|
|
I have a button on my form. i want to raising the button`s click event.
|
|
|
|
|
Since no-one else seems to answer, I'll jump in:
Very easily by calling myButton.PerformClick();
But beware PerformClick(): It only works when the button is selectable.
When you for example derive a control from button and set its control style to Selectable==false, then PerformClick on this control will have no effect.
Regards,
mav
|
|
|
|
|
thank you.
I have an another question.
how I can rais an desired event(not only Click)?
|
|
|
|
|
There's no consistent way for doing this.
If you want to raise the event from a derived control, then usually the base class offers protected OnEvent... methods to call, but if you're trying to raise an event from a different class than you're probably out of luck.
You usually have to call a method/set a property of the object you want to fire the event in such a way that the event desired is fired.
For example, if you want the TextChanged event of a TextBox to fire you can call
myTextBox.Text = "Some new Text"; and the event gets fired.
If you already have an event handler in your class for the desired event, then you can simply call this method by yourself.
For example:
button1.Click += new EventHandler(this.button1_Click);
...
this.button1_Click(this, new EventArgs());
Regards,
mav
|
|
|
|
|
Does anyone know when the new release for SQL Server and the MSDN will be launched? I am thinking of buying an MSDN subscription, but I don't want to buy if I know if there is a new version coming soon.
Brendan
|
|
|
|
|
If you buy an MSDN Subscription you get all the new software available to you as soon as it comes out. That's why it is called a "Subscription".
|
|
|
|
|
Is there any way to add some controls on a frame windows in SDI/MDI applications (NOT toolbars) ?
|
|
|
|
|
Is there anyone that would have an example of how to change the wallpaper using the systemparametersinfo. How do you use it, what needs to be impoted and an example code would be nice.Thanks.
|
|
|
|
|
How can I display more than 10 projects in the Start Page? (in studio)
"For all of our languages, we cannot communicate" - Christy Moore, Natives
|
|
|
|