|
Pain_Elemental wrote:
Win32APIfunctions.SetupDiGetDeviceInterfaceDetail(NewDeviceInfoSet, ref devInterfaceData, out devInterfaceDetailData, 0, out uiRequiredSize, out devInfoData); int iLastError = Marshal.GetLastWin32Error();
Why are you checking for the last error, if you dont even know if there is one!? Test the return value of the call. That could be dirty data, or maybe you reading the number wrong...
top secret xacc-ide 0.0.1
|
|
|
|
|
Well, the only return value of interest is uiRequiredSize, but this is always 0.
By the way, I always check for last error just for debugging perpose.
-------------------------------------------
The light at the end of the tunnel has been switched off temporarily due to budget problems...
|
|
|
|
|
I forgot to set SetLastError=true at the import statement.
Now I get an other error code.
Here's my piece of code again:
Win32APIfunctions.SP_DEVICE_INTERFACE_DATA devInterfaceData = new Interfaces.Win32APIfunctions.SP_DEVICE_INTERFACE_DATA();
devInterfaceData.cbSize = (uint)Marshal.SizeOf(devInterfaceData);
Win32APIfunctions.SP_DEVICE_INTERFACE_DETAIL_DATA devInterfaceDetailData = null;
Win32APIfunctions.SP_DEVINFO_DATA devInfoData = null;
uint uiRequiredSize=0;
if(!Win32APIfunctions.SetupDiGetDeviceInterfaceDetail(NewDeviceInfoSet, ref devInterfaceData, out devInterfaceDetailData, 0, out uiRequiredSize, out devInfoData))
{
int iLastError = Marshal.GetLastWin32Error();
Win32Exception myEx = new Win32Exception();
throw new System.ApplicationException(myEx.Message, myEx.InnerException);
}
Now I get
Error code: 1784
ERROR_INVALID_USER_BUFFER: The supplied user buffer is not valid for the requested operation.
I think that possibly this could be the problem:
Win32APIfunctions.SP_DEVICE_INTERFACE_DATA devInterfaceData = new Interfaces.Win32APIfunctions.SP_DEVICE_INTERFACE_DATA();
devInterfaceData.cbSize = (uint)Marshal.SizeOf(devInterfaceData);
Am I allowed to cast to uint here?
-------------------------------------------
The light at the end of the tunnel has been switched off temporarily due to budget problems...
|
|
|
|
|
I use a PictureBox array in my project;
<br />
public PictureBox[] illustration;<br />
illustration = new PictureBox[10];<br />
...<br />
myInkPicture[IntSelectPage].illustration[i] = new System.Windows.Forms.PictureBox();<br />
...<br />
myInkPicture[IntSelectPage].illustration[i].MouseDown += new System.Windows.Forms.MouseEventHandler(myInkPicture[IntSelectPage].illustration_MouseDown);<br />
the ten PictureBoxes use the same MouseDown event handler,
<br />
public void illustration_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)<br />
{<br />
pictureBox1.Capture = true;<br />
startMoveLocation = new Point(e.X, e.Y); <br />
}<br />
I want the pictureBox1 to be the illustration[i] ,
How can I typecast the object sender to be the illustration[i] PictureBox...??
|
|
|
|
|
Hi,
In your mouse down event handler sender is the object that caused the event. In this case it will be whatever picturebox the mouse went down over. I believe that by casting sender to a picturebox you will have the picturebox that the mouse went down on aka illustration[i].
Do this with ((PictureBox)sender).Capture = true;
Karl
|
|
|
|
|
I have tried and it really works !!
Thank you very much
|
|
|
|
|
Ok guys, I've done my research and I have found great articles here that really gave me a kickstart on updating the UI by calling Invoke on the main thread from a worker thread. But I'm trying to apply this knowledge to an application which uses delegates to perform asynchronous calls without sucess. Here is the interesting situation:
I have a delegate declared outside the windows form class resposible for the UI updates
public delegate void delegateUpdateStatus(string msg);
then there is the delegate which I use for the asynchronous calls (inside the form class)
public delegate void delegateAsynch(parameters here);
in the click event of a button I create an instance of the asynchronous delegate
delegateAsynch myAsynchDelegate = new delegateAsynch(target function)
then I use the BeginInvoke method on the asynchronous delegate and works perfectly great. Now I have decided to update the UI with a label giving feedback of the progress. That's where the first delegate declared above comes in. The problem is that in the target function I make a call to Invoke like:
Invoke(new delegateUpdateStatus(updateStatus), new object[] {"Hello"});
or BeginInvoke(new delegateUpdateStatus(updateStatus), new object[] {"Hello"});
and the application goes to a zombie state with any of those statements without even modifying the UI (I tried only one of those statements on different runs). I have carefully placed breakpoints to see where it is hanging but after any of those lines is executed no other instruction is called, not even the method (updateStatus) the delegate is supposed to call. It is worth noting that Intellisense really knows that Invoke or BeginInvoke comes from Control. I have slapped against a wall, please help!
|
|
|
|
|
Make sure you check Control.InvokeRequired before calling Control.Invoke or Control.BeginInvoke to determine if invoking is even necessary. If it is not required, just call updateStatus directly. Since yo're using async invocation, it should be required but it was just a thought. I do this quite a bit in our enterprise app and have never had a problem.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thank you Stewart for your reply. After reading your post I put the call to the update delagate in an if statement with the condition lblStatus.InvokeRequired . To my surprise the InvokeRequired property always returned false. How can this be if before using asynchronous delegates the UI freezed. Now that I'm using async invocations the UI is responsive as it should be. Also, a direct call to the updateStatus method does not update the UI, although the program does not enter a zombie state. Any ideas!? The fact that the lblStatus.InvokeRequired returned false got me confused with async invocation using delegates.
|
|
|
|
|
I have a search for a Client/Server Framework Developer.
You will use C#, XP, agile, and paired programming in a large shop in a suburb of Cleveland.
Please contact me if you are interested.
Thanks!
Dick Ellison
ellisor@aol.com
|
|
|
|
|
|
When you create a Windows forms project in VS .NET 2003 you get a file called App.ico, right? So I started drawing in it to get my own icon. I then took the main window and went to the Icon property. I pressed the button there and chose the App.ico file in the project folder. This doesnt work. The exe file created has the standard icon and so does the program when it starts. If I open the ico file in VS it looks just like I drew it.
I used the same icon for a contextmenu and it works there. When I minimize the program to the system tray I have the correct icon there but the program doesnt.
By the way, an *.ico file should look like the icon itself when I look at it in an explorer window, right?
Thanks
|
|
|
|
|
Hi,
I am not sure if this is your problem or not. Icon files can have multiple versions of the icon, most commonly a (16x16 and 32x32) when the icon is being used the appropriate version is used. The default icon has both 16x16 and 32x32 versions, if you only changed one of them there will be some situation where the one you didn't change is used.
To change the other version open the icon in the editor. Right click in the editing window (but not on the icon) and in the list that appears there will be "Current Icon Image Types".
Hope this helps,
Karl
Karl Baum
CEO of KGB Technologies
Specializing in custom software development.
|
|
|
|
|
It s a bug in VS, that doesnt refresh it resources. Just remove the file (not delete) so VS can know something happened to it (just build or something to create an error), then just re-add it.
top secret xacc-ide 0.0.1
|
|
|
|
|
I managed to get both the problems you described. Your solutions solved it. Thanks!
|
|
|
|
|
Hi All
I've got a remoting situation setup where the server class is running in a windows service from my server. I have setup a test on the client that gets this remote server class and call methods on it. My test method just says .AreYouThere() and returns a string that says "Yes". This works fine. My next method test was to return a custom class that wraps an arraylist and just contains a list of years.
When I create a method on my remote server class called .GetYears() it should return a Years object. But my application bombs out at this point... My remote server class is setup like this...
public class RaceServerClass : MarshalByRefObject
do I have to setup my object that I want to pass back with that as well... or do they need something else special.
Thanks
Bryan
|
|
|
|
|
Returning MarshalByRefObjects across remoting boundaries can be a security flaw; in .NET 1.1 Microsoft made the passing of object references throw an exception. There is a way around this, you must specify TypeFilterLevel as full when registering your channel. For instance, through code:
BinaryServerFormatterSinkProvider serverProv = new BinaryServerFormatterSinkProvider();
provider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
props = new HashTable();
props["port"] = 2264;
HttpChannel chan = new HttpChannel(props,
new BinaryClientFormatterSinkProvider(), provider);
ChannelServices.RegisterChannel( chan );
It can also be done through the server & client .config files. For more information, see this page[^].
#include "witty_sig.h"
|
|
|
|
|
Oh I should mention, if you don't need to modify the actual Years object on the client side, then don't make it MarshalByRefObj. Just add the [Serializable] attribute to the beginning of the class and you'll be able to pass a copy of the years object across remoting boundaries without problems.
#include "witty_sig.h"
|
|
|
|
|
I had actually found source similiar to the one you posted about giving full control and have implemented that. I'm guessing that my years object that my remote server object is returning needs the marshalbyrefobj... I plan on modifying it. I will try it tonight and post back if I have problems.
Thanks for the post!
|
|
|
|
|
I don't remember much about what I studied about remoting but here's something to start with. Are you serializing the class? Like:
[Serializable]
public class myClass
{
...
}
|
|
|
|
|
What do you mean "bombs out"? Any object being passed around remoting must be derived from MarshalByRefObject because it must cross application boundries.
If you can actually give an exception object or the exception method that would be helpful.
Also a pitfall almost everyone new to .Net Remoting (as well as any other remote procedure framework) is that since objects live in two different application domains they aren't exactly equal. It is even warned in the MSDN documentatino:
<br />
Types must inherit from MarshalByRefObject when the type is used across application domain boundaries, and the state of the object must not be copied because the members of the object are not usable outside the application domain where they were created.<br />
So if your server twiddles the value of the object passed to it, those values are lost to the client upon leaving the method.
|
|
|
|
|
Heres an update...
I made all my data objects use MarshalByRefObject. What I meant by "bombs out" was that my application was causing an error that wasn't an exception in .net... it was generating a windows error... but I fixed that.
I now have this up and running and it works good. Heres a small example of what I'm doing. I'm building a race management software suite ( backend, web admin, public web, admin winform ). I wanted all to be able to use the same backend so I thought I would use .Net Remoting to provide a service for the other three to use to access the data from the db.
Thanks for the help.
Bryan
|
|
|
|
|
Dear, Sir and Madam
When I set SelectedObject property of PropertyGrid to DataTable and click ellipses button to modify Coloumns property of DataTable
the "DataColumn Collection Editor" appear. But Add and Remove button of this dialog is disabled Is it possible to Enabled them to allow user add and remove via this dialog
Sorry for bad English.
Thank You.
|
|
|
|
|
I assume you're doing this at runtime. There are a number of designer interfaces - like IWindowsFormsEditorService - that you need to provide by the container (whatever is hosting the DataGrid ), as well as implement ISite and set that on the child controls.
The design-time environment is much different from the runtime environment, and in the design environment the IDE (VS.NET, #develop, whatever) provides these services to make TypeConverter s and UITypeEditor s (among other things) possible.
Read-up on the design-time model in the .NET Framework SDK. There's a lot you need to know and understand.
Besides, another reason - most likely the problem - is that the Add and Remove buttons are disabled because the designer cannot serialize to source - there is no source since you're running a compiled executable.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I would like to allow my users the opportunity to update changes on a control in a particular tab when they try to leave. To do this I use the user control thats loaded into the tab's Validating event (Catching the event in the tabbedcontrol itself will not find the changes). The event is caught and a dialog box is fired off to ask whether or not theyd like to leave.
Problem 1: the Validating event is fired twice when a user tries to leave the tab.
Problem 2: the call to e.cancel = true gets enforced not on the two times when its leaving, but rather when the tab is getting the focus once again, ie the cancel call doesnt do anything until you leave the tab and then try and come back.
Any suggetions?
Thank You
Robert
|
|
|
|