|
Hi, I want to use message queues to send a class, which includes a bitmap. Creating, connecting and sending is no problem and receiving in the same application works just as well. But the same code in an other application throws a "SerializationException"
The code I use for the server application:
private void MainLoad(object sender, EventArgs e)
{
MessageQueue.Create(@"MYPC\MyQueue", false);
MessageQueue queue = new MessageQueue(queueName);
queue.BeginPeek(TimeSpan.FromDays(10.0),messagenumber++, new AsyncCallback(MyPeekCompleted));
}
private void MyPeekCompleted(IAsyncResult asyncResult)
{
MessageQueue queue = new MessageQueue(@"MYPC\MyQueue");
queue.Formatter = new BinaryMessageFormatter();
System.Messaging.Message msg = queue.Receive(TimeSpan.FromDays(10.0));
Protocol p = (Protocol)msg.Body;
queue.BeginPeek(TimeSpan.FromDays(10.0), messagenumber++, new AsyncCallback(MyPeekCompleted));
}
private void ButtonSendClick(object sender, EventArgs e)
{
MessageQueue queue = new MessageQueue(@"MYPC\MyQueue");
Bitmap bmp = new Bitmap(@"D:\lena.gif");
Protocol p = new Protocol();
p.text = "test";
p.sender = senderID;
p.receiver = "Client";
p.bitmap = bmp;
System.Messaging.Message m = new System.Messaging.Message(p, new BinaryMessageFormatter());
queue.Send(m);
}
Protocol is a class:
[Serializable()]
public class Protocol
{
public string sender;
public string receiver;
public string text;
public System.Drawing.Image bitmap;
}
The code I use for the client application:
private void MainLoad(object sender, EventArgs e)
{
MessageQueue queue = new MessageQueue(@"MYPC\MyQueue");
queue.BeginPeek(TimeSpan.FromDays(10.0),messagenumber++, new AsyncCallback(MyPeekCompleted));
}
private void MyPeekCompleted(IAsyncResult asyncResult)
{
MessageQueue queue = new MessageQueue(@"MYPC\MyQueue");
queue.Formatter = new BinaryMessageFormatter();
System.Messaging.Message msg = queue.Receive(TimeSpan.FromSeconds(10.0));
Protocol p = (Protocol)msg.Body;
queue.BeginPeek(TimeSpan.FromDays(10.0), messagenumber++, new AsyncCallback(MyPeekCompleted));
}
modified 4-Jul-13 4:51am.
|
|
|
|
|
A colleague of mine solved it today, if the protocol is in a DLL, there no problem anymore.
|
|
|
|
|
I want to know how to connect in LAN and use the Message Queue to send messaged to the connected Pcs. I am working in C# language and OS is Win 7.
|
|
|
|
|
Well, the ?NET framework has this[^] available.
|
|
|
|
|
Thanks for the article. And you should respect elders ! It will be good for you.
|
|
|
|
|
You're welcome. Any the elders bit was a joke about how old I am.
|
|
|
|
|
Hi everybody,
I have a user control that has a webbrowser in it. I've used a user control to see where to put controls on an html form.Everything is great except the fact that I can't move (drag and drop) controls like textbox and datagrid over this user control and it is making this hard to place controls in their right position.
Please help me solve this issue,
Thanks.
P.S : I am using Windows Forms Application
Every new thing you learn,Gives you a new personality.
|
|
|
|
|
I wanted to have a spirited discussion on a valid use case for screen size dependent forms design. I'd like to make it clear though, I'd love an alternative that fits my use case and is size independent.
So, here it goes:
Use Case
I develop applications for use in industrial control systems. The point of these screens is to place as much relevant information on a single display as possible while not overcrowding the display. This often includes piping diagrams, large gauges (as to be read from a distance or at a glance). The screen sizes are usually fixed at around 21" or 23" (widescreen is just breaking in) and are touch screen only (no keyboards).
Case for Big Screens
I really would love to discuss with developers who make blanket statements about big screens mean you are doing something wrong.
Here is an example screen
The above screen is a sample, the requirement is to show everything related to the pits on one screen so that while the operator is doing a particular operation they do not have to switch screens to see any of the data. The screen is actually from an HMI designer that I use (and designed) that uses Windows Forms as the back-end.
Now, knowing that we have:
1: A fixed screen size.
2: A product that we control what it runs on (we also provide the screens/computers)
3: Requirement from the user about what is shown.
4: Winforms back-end.
5: The designer does not have access to the code (HMI designers are NOT programmers, so they are not given or expected to write code, they just place stuff on the display and tie it to external devices through a binding interface).
How could we make this size independent? This is why, at least for me, Windows Forms limitation of 12px over the designer screen resolution is a PITA. Our field engineers making changes to screens typically use laptops to edit screens that run on 23" monitors, so every time they open a screen, WF graciously resizes them (thanks MS!).
Use for MDI
Aside from the system running full screen (we don't want the user to be able to access the desktop), we use an MDI window in the background to make sure that all the screens stay on the display they are assigned to. The application can be assigned to run on a certain display and we don't want the user to change that. So we use MDI as the container for the windows so that even if the form has a title bar, the user cannot drag them outside of the screen.
If somebody has a really cool way of doing what I need I'm all ears, but I think we should all stop assuming that because somebody says they need the screen bigger that they are doing it wrong fundamentally, since we don't fully understand the use case...
|
|
|
|
|
I also work a lot at industrial automation. Unfortunately, there are a lot of bad trends in UI in the industry, and the fixed or fluid design is one of the pain points.
Often, developers don't understand specific needs of the people working in the industry. From the other hand, many of their "requirements" are just the ridiculous artifact of their inertial of thinking and bad habits inadequate to computing, such as the habit to work with the old-time devices. This week, I work with oscilloscopes which themselves run Windows 7.
One especially ridiculous trend it to imitate old analog gauges and scales, with all kinds of shadows and destructing highlights, where a simple numeric display could do the best. I cannot understand vanity of those people, such efforts look miserable to me. There is a trend to use two buttons for on and off, where a check box is the most compact and intuitive.
At the same time, it would be wrong to make bold generalization. In particular, it is important to see a difference between different types of UI, in two aspects: purpose and... touch screen vs. keyboard/mouse.
People cannot do UI for touch screen, face it. Windows and other general-purpose Windowed systems don't provide adequate support. People cannot nicely point a close box with a finger (even with keyboard/mouse, hitting it with a mouse is a mouse is a bad habit which causes fatigue, irritation and poor performance).
One important thing to understand: people use their motoric memory. The body remembers where to click. But this is so only with well-designed touch screen and is not quite applicable to keyboard interface, where fluid design can prevail.
One thing is most certainly failing in usability: MDI. It should be exterminated from everywhere by all means. Microsoft is trying hard to phase it out, for some good reasons. The second thing to get rid of is multiple windows interface. I don't count some modal dialogs, but only if there are not too many of them, and only when the modality is really well motivated, not just by the simplicity of development.
—SA
Sergey A Kryukov
|
|
|
|
|
The type of information display (getting a little off topic I guess) is indeed not the most efficient or concise way to display it I do agree, however I don't think that we can also make a statement that its not useful in all situations. The industry I work in for example (similar to yours), its much easier to interpret quickly a needle pointing to a red range on a gauge than look at a number and ask if its within normal range or getting close to something dangerous. I don't believe that in the industrial automation world that there will ever be a replacement for analog gauges even digitally represented.
A good case study of this is glass cockpits (I'm also a pilot), where it takes a lot longer to interpret numeric data than graphical. Pilots have a few seconds to scan gauges before getting eyes back outside where they need to be. To me, glass cockpit gauges are the best representation because if you notice, they don't have numbers on them, just a needle and colors. The numeric data is underneath. The scale is distracting and doesn't give any additional information...
That being said (and more back to the point), sometimes the best way to represent data isn't the one that makes the most efficient use of space. On top of that we need to logically group data so that its presented in a way that doesn't require the user to switch displays too often.
Maybe a "single form" UI design is the answer to some of that, and maybe WPF is another piece of the puzzle because it's more vector based than raster, but in the world of industrial automation we just aren't there yet.
MDI was a useful container for what we were attempting to accomplish. It provided a container for forms so that they couldn't be moved outside the assigned display (the IA applications we use sometimes use multiple screens from the same computer for 2 users). I still haven't found another way to accomplish this without code-behind.
I'm still not convinced (not saying you aren't convincing, just in general ) that the single form UI Microsoft is moving to is increasing productivity or usability. If we all worked on tablets I would say yes, but we all still work on multiple monitor, multi-tasking computers and the concept doesn't seem well thought out yet...
|
|
|
|
|
Even though you made some good points, I cannot agree with your response on MDI and single-window interface (I hope you understand that I spoke of rich interface where the role of separate windows is played by tabs, expanding/docking panels or other similar elements). As to WPF, I don't know who is "not there". I used to develop WPF-only product, some 4 years ago, and started with WPF even earlier...
—SASergey A Kryukov
|
|
|
|
|
Quote: ... Our field engineers making changes to screens typically use laptops to edit screens that run on 23" monitors, so every time they open a screen, WF graciously resizes them (thanks MS!).
Here is a hack to deal with that frustration. Inherit from this Form instead of Forms.Form.
Imports System.ComponentModel
Imports System.Runtime.InteropServices
Public Class FormWithDesignSize
Inherits Form
Private Const DefaultMax As Int32 = 2000 'set this to whatever you need
Private _MaxDesignWidth As Int32 = DefaultMax
Private _MaxDesignHeight As Int32 = DefaultMax
<Category("Design")> _
<DisplayName("MaxDesignWidth")> _
Public Property aaa_MaxDesignWidth() As Int32 'Prefix aaa_ is to force Designer code placement before ClientSize setting
Get ' avoids need to write customer serializer code
Return _MaxDesignWidth
End Get
Set(ByVal value As Int32)
_MaxDesignWidth = value
End Set
End Property
<Category("Design")> _
<DisplayName("MaxDesignHeight")> _
Public Property aaa_MaxDesignHeight() As Int32 'Prefix aaa_ is to force Designer code placement before ClientSize setting
Get ' avoids need to write customer serializer code
Return _MaxDesignHeight
End Get
Set(ByVal value As Int32)
_MaxDesignHeight = value
End Set
End Property
Protected Overrides Sub SetBoundsCore(ByVal x As Int32, ByVal y As Int32, ByVal width As Int32, ByVal height As Int32, ByVal specified As BoundsSpecified)
If Me.DesignMode Then
' The Forms.Form.SetBoundsCore method limits the size based on SystemInformation.MaxWindowTrackSize
' From the GetSystemMetrics function documentation for SMCXMINTRACK:
' "The minimum tracking width of a window, in pixels. The user cannot drag the window frame to a size
' smaller than these dimensions. A window can override this value by processing the WMGETMINMAXINFO
' message."
' See: http://msdn.microsoft.com/en-us/library/windows/desktop/ms724385%28v=vs.85%29.aspx
' This message also appears to control the size set by the MoveWindow API,
' so it is intercepted and the maximum size is set to MaxWidth by MaxHeight
' in the WndProc method when in DesignMode.
' Form.SetBoundsCore ultimately calls Forms.Control.SetBoundsCore that calls SetWindowPos but,
' MoveWindow will be used instead to set the Window size when in the designer as it requires less
' parameters to achieve the desired effect.
MoveWindow(Me.Handle, Me.Left, Me.Top, width, height, True)
Else
MyBase.SetBoundsCore(x, y, width, height, specified)
End If
End Sub
Private Const WMGETMINMAXINFO As Int32 = &H24
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
MyBase.WndProc(m)
If Me.DesignMode AndAlso m.Msg = WMGETMINMAXINFO Then
Dim MMI As New MINMAXINFO
' retrieve default MINMAXINFO values from the structure pointed to by m.LParam
Marshal.PtrToStructure(m.LParam, MMI)
' reset the ptMaxTrackSize value
MMI.ptMaxTrackSize = New POINTAPI(_MaxDesignWidth, _MaxDesignHeight)
' copy the modified structure back to LParam
Marshal.StructureToPtr(MMI, m.LParam, True)
End If
End Sub
<StructLayout(LayoutKind.Sequential)> _
Private Class MINMAXINFO
Public ptReserved As POINTAPI
Public ptMaxSize As POINTAPI
Public ptMaxPosition As POINTAPI
Public ptMinTrackSize As POINTAPI
Public ptMaxTrackSize As POINTAPI
End Class
<System.Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential)> _
Public Structure POINTAPI
Public X As Int32
Public Y As Int32
Public Sub New(ByVal X As Int32, ByVal Y As Int32)
Me.X = X
Me.Y = Y
End Sub
Public Overrides Function ToString() As String
Return "(" & X.ToString() & ", " & Y.ToString() & ")"
End Function
End Structure
<DllImport("user32.dll")> _
Private Shared Function MoveWindow(ByVal hWnd As IntPtr, ByVal x As Int32, ByVal y As Int32, ByVal nWidth As Int32, ByVal nHeight As Int32, ByVal bRepaint As Boolean) As Boolean
End Function
End Class
|
|
|
|
|
If I could vote twice I would, thank you. I've been trying to find a good solution for this for a while now.
I owe you a 12-pack.
|
|
|
|
|
You are welcome. I'm glad you find it useful.
|
|
|
|
|
Hi there!
I have a dll with its lib file which i can't add them into my project.
The dll contains functions of a data card which i want to use for data acquistion.
I have uploaded the mentioned files here.
<a href="http://filecloud.io/e87rwzvp">http://filecloud.io/e87rwzvp</a>[<a href="http://filecloud.io/e87rwzvp" target="_blank" title="New Window">^</a>]
<a href="http://filecloud.io/j8rvzg57">http://filecloud.io/j8rvzg57</a>[<a href="http://filecloud.io/j8rvzg57" target="_blank" title="New Window">^</a>]
I'll appreciate it if anyone can help me with that.
Thanks in advance.
|
|
|
|
|
I'm not going to download random code.
Are these .NET assemblies? If not, then referencing them will not work - you'd need to P/Invoke them. Does the manufacturer supply an SDK?
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
hi
thanks for your attention
it does not said anything about dll to be in .net framework or not.
i have guessed that it should be .net from the manual and functions provided there.
and those uploaded files are not my code. they are dll and lib files.
|
|
|
|
|
You can't write code by "guessing". You'll need to know what methods are available, and only the manufacturer knows how the device talks to the system (what the driver is capable of)
Bastard Programmer from Hell
If you can't read my code, try converting it here[^]
|
|
|
|
|
You can only set a reference the .DLL's that are COM-based or .NET-based. Other than that, you MUST have the documentation on what functions the .DLL's export and what types their parameters and return values are and use P/Invoke to call them instead. This is information that you have to get from the manfucturer of your device.
|
|
|
|
|
thanks Eddy Vluggenand and Dave Kreskowiak
I used P/Invoke and it seems it will work with that.
As you mentioned there is just a manual with functions of dll and their parameters.
I will check soon.
Thanks again
|
|
|
|
|
I have created asp.net web application in windows 7. I am able to run locally but i am not able to run from other system.
What could be the possible reason.
If anybody knows, please reply me.
Thanks in advance.
|
|
|
|
|
Where is it hosted - locally? What do you mean with "run from other system" - viewing it in a browser or hosting it?
What about the firewalls? Which server do you use - IIS or something else?
|
|
|
|
|
|
Can you specify the error showing while running on other system I am faced lot of problem related COM components. Some errors can fix by setting necessary privileges for com components . By using DOM settins
|
|
|
|
|
Hello,
I'm recreating the Fenêtre Volante screensaver from the Mac for Windows. I know you can rename a *.exe file to *.scr, and Windows will recognize it as a screensaver when it's in the %WINDIR%\System32 directory.
I'm creating it on a Windows 8 (x86) device, and it is running fine in any directory. It also runs fine when I test it on another Windows 8 device (also x86).
When I'm testing the same .scr file on two Windows 7 (x64) computers in the System32 directory, it says it can either not find the required runtime or it just can't start because the SHIM version cannot be determined or something like that.
But when the executable is not in the System32 directory, it runs fine.
I've tested this with both .Net Framework 4.0 and 4.5.
The screensaver is using the Application Settings to save the screensaver settings.
Can anybody please help me?
Paul van der Stel
|
|
|
|
|