|
|
I have a .NET Winform served up by a IIS server. I'm also accessing .NET Web services. When referencing the .NET Web services, the paths are hard coded. I need to setup a relative path for application deployment purposes. Can anyone help?
Thanks,
Shane
Shane L. Hatcher
|
|
|
|
|
The WinForm doesn't really know where it's running from, but there are solutions. First, it'd be nice if you could use the Value of the Url evidence presented to your AppDomain, but when a control is hosted in IE, this is always *just* the same name (MSDN Support claimed that was intentional...whatever). What you could do, however, is some of the following things:
1. Use AppDomain.CurrentDomain.BaseDirectory to get where the WinForm is running; however, this is not always correct (circumstantial, but usually correct).
2. Add a public property to your form as a string (the URL to the Web Service) and use a <param /> tag using the property name as the name and the value as the URL. Then, bind to the Web Service dynamically.
3. Specify this in your <appSettings /> section of your form's client .config file (make sure to change the handler from *.config to Web.config in your machine.config file, otherwise your form can't access its own configuration file!).
These are just a few ideas. #1 is probably the best (although prepare that - for some rare reason - the APPBASE is wrong) if you always want them to have the same relative path, but #2 and #3 allow your clients to specify different paths (perhaps even on different servers) to suite their needs.
"Well, I wouldn't say I've been missing it, Bob." - Peter Gibbons
|
|
|
|
|
Is there a way to get a raised Panel, the Border style property allows only FixedSingle, Fixed3D or None and Fixed3D only produces a sunken panel.
There is another border property Border3DStyle which allows things like SunkenInner, Raised, RaisedInner,RaisedOuter, Sunken, SunkenInner, SunkenOuter but that is for the Panel parent class.
If I could view/modify this property for a panel it would be great.
A C# example would be great. I will be creating a panel on the fly in my code.
Cheers in advance
|
|
|
|
|
I cant help you in c# but the ControlPaint class has what your looking for:-
ControlPaint.DrawBorder(_FormAreaG, Me.DisplayRectangle, Color.FromKnownColor(KnownColor.ControlLight), ButtonBorderStyle.Outset)
You have to redraw this in the paint event.
|
|
|
|
|
Change "Me" to "this" and it'll work in C#. Remember, the .NET framework provides the same class library for every language - it's only a matter of syntax.
"Well, I wouldn't say I've been missing it, Bob." - Peter Gibbons
|
|
|
|
|
Thanks to all, I have tried 2 slightly different calls based on the original code which do give different results but both work well.
ControlPaint.DrawBorder( pe.Graphics, this.DisplayRectangle, Color.FromKnownColor(KnownColor.ControlLight), mButtonBorderStyle);
ControlPaint.DrawBorder3D( pe.Graphics, this.ClipRectangle, mBorder3D);
|
|
|
|
|
I'm having a problem showing my context menu. One of the options is delete,
which deletes a control of a form. The menu is displayed with :-
PopMenu.Show(Me, Me.PointToClient(New Point(MousePosition.X,
MousePosition.Y)))
But after I've deleted a control I get this wierd error message:-
ContextMenu cannot be shown on an invisible control.
The control is obviously still visible so why does it do this?
|
|
|
|
|
I don't know how your PopMenu is initialized and attached but what I know is that .NET context menus are automatically shown on right-clicks, and they have to be preably attached to the control with the .ContextMenu property. You never call Show(), or you expose yourself to such things.
Using Show() directly is a hack. The executed code is as follows :
public void Show(Control control, Point pos) {
object[] local0;
if (control == null) {
local0 = new Object[2];
local0[0] = "control";
local0[1] = "null";
throw new ArgumentException(SR.GetString("InvalidArgument", local0));
}
if (!(control.IsHandleCreated) || !(control.Visible))
throw new ArgumentException(SR.GetString("ContextMenuInvalidParent"), "control");
this.sourceControl = control;
this.OnPopup(EventArgs.Empty);
pos = control.PointToScreen(pos);
SafeNativeMethods.TrackPopupMenuEx(this.Handle, 64, pos.X, pos.Y, control.Handle, null);
}
Make sure the associated control .Visible property is set to true. When the code reaches TrackPopupMenuEx, it relies on standard WIN32 menus, and at this point you are sure the context menu displays well.
|
|
|
|
|
Thanks Rod,
The problem I've found out is to do with my subclassing, even using the method you suggested it bombs, but I have now found out that it's a windows message thats bombing it thanks to your advice
|
|
|
|
|
It's WM_CONTEXTMENU that is causing the app to bomb.
When the message is passed down the chain (MyBase.WndProc(message)) it bombs with the not visible error.
I can't find TrackPopupMenuEx in the net framework, do you know where I'd find it?
|
|
|
|
|
LeeDaviesVBSource wrote:
I can't find TrackPopupMenuEx in the net framework, do you know where I'd find it?
That's not TrackPopupMenuEx(...), that's SafeNativeMethods.TrackPopupMenuEx(...), where SafeNativeMethods is a namespace of WIN32 imported functions defined like this :
[DllImport("user32.dll")]
public extern static bool TrackPopupMenuEx(IntPtr hmenu,
int fuFlags,
int x, int y,
IntPtr hwnd,
TPMPARAMS tpm);
which at run-time is interoped to a native WIN32 ::TrackPopupMenuEx(HMENU hmenu, UINT fuFlags, int x, int y, HWND hWnd, LPTPMPARAMS tpm) call.
This method call is proven. What could be wrong at this point is the hmenu (invalid or NULL), or a NULL owning window handle (hWnd). The last parameter can be NULL.
|
|
|
|
|
I have found the problem, not solved it, but found it
It's the subclassing routine I'm using. For some reason the controls are changing their handles. I got the code off here so I'll go bug the AngryCoder and see if he can help!
Thanks
|
|
|
|
|
Is there a way to make a fullscreen form (real not fake) with .NET means (fullscreen like the one in MS Word)?
If there is no pure .NET way how can it be done at all?
|
|
|
|
|
I've got a problem with the XmlSerializer - i can't seem to serialiaze custom types. The XmlSerializer works fine with any BCL type, but my custom types throw this error:
An unhandled exception of type 'System.InvalidOperationException' occurred in system.xml.dll<br />
<br />
Additional information: There was an error reflecting 'ComponentTestConsole.CustomType'.
I wonder if it's a security thing (even though it's not a security exception), since this is the first project i've created on a network drive and it did warn me when i started the project yesterday. So as a second question, what do i need to do to let .NET know that my network shares are safe as houses?
Thanks in advance,
Paul
|
|
|
|
|
Have you implemented the serializable interface in your classes?
|
|
|
|
|
Hi Lee,
I was just about to post to say i've fixed it. I hadn't looked in the InnerException member of the thrown exception - i'd stupidly not made my custom type public (doh!).
You don't need to implement the serializable interface to use the XmlSerializer - it uses reflection to inspect the type and serialize any publicly accessible members.
Cheers,
Paul
|
|
|
|
|
I beleive that the xml serializer requires the class to have a public parameter-less constructor. Does yours have one?
|
|
|
|
|
Thanks, but i've fixed it now.
see post above.
|
|
|
|
|
I know I can get a string as a char[], but I need to build a string and get it as a byte[]. Can it be done ?
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
In the System.Text namespace, there are a bunch of classes ending with Encoding. They have a method called GetBytes with a bunch of overloads. So in the case of Unicode text, you would use:
byte[] string2byte = System.Text.UnicodeEncoding.GetBytes("This is a string");
I don't know whether it's just the light but I swear the database server gives me dirty looks everytime I wander past.
-Chris Maunder
Microsoft has reinvented the wheel, this time they made it round.
-Peterchen on VS.NET
|
|
|
|
|
Why do you need it as a byte[]?
|
|
|
|
|
I didn't in the end. I am using a StringBuilder to build a report from a DataSet, which I then want the browser to save to the users HDD. The code I was basing it on streamed all sorts of things and so used Response.BinaryWrite. I only need Response.Write, as it is always a string ( obviously ). It all works now, with the exception that it insists on ignoring the directive to set the filename, instead saving my test with the name of my aspx.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|
Great! So my hard work was for nothing?
[edit]Actually, I have noticed that Response.Write doesn't pay attention to the filename, which is a real shame, cause then the user isn't able to open it automatically. I have seen it several times, but still have no idea how to fix it. /edit]
Hey, what can I say? I'm a chick magnet...a babe conductor...a logarithm for the ladies.
-Strong Bad from HomeStarRunner.com
Essential Tips for Web Developers
|
|
|
|
|
David Stone wrote:
Great! So my hard work was for nothing?
No, I was really pleased to know the answer, and filed it away for future reference.
Current thought has it that my IIS is stuffed, because the same code works on other peoples machines.
Christian
No offense, but I don't really want to encourage the creation of another VB developer.
- Larry Antram 22 Oct 2002
C# will attract all comers, where VB is for IT Journalists and managers - Michael
P Butler 05-12-2002
Again, you can screw up a C/C++ program just as easily as a VB program. OK, maybe not
as easily, but it's certainly doable. - Jamie Nordmeyer - 15-Nov-2002
|
|
|
|
|