|
If you want to log the IP address of the machine making the request to your web service, all you need to do us is get Context.Request.UserHostAddress inside a method call in your web service (Context is a property inheritted from the WebService from which your web service derives).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks so much for your help, this is exactly what I needed.
|
|
|
|
|
We have a beta .NET/C# application that we release every couple for client computers to install. They install it over their previous version.
We are finding that there are multiple entries in the Add/Remove Programs section even though there is only one installation on their machine - I assume that there is one entry per upgrade.
Any way to avoid this without manually removing the excess entries from the Add/Remove Programs?
|
|
|
|
|
Make sure in your installer project you set RemovePreviousVersion is set to True and always keep the UpgradeCode the same. To fix any current problems, you can use Orca (from the Windows Installer SDK) to add the necessary entries to the Upgrade table in your installer package (.msi file). See the Windows Installer SDK on MSDN[^] for more information.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi!
I read some articles about P/Invoke and how to call Win32 API functions.
Now I wonder: when does the runtime load the DLLs and when does it free it?
Does it load the DLL when the external function is needed and frees it immediately after calling (so many calls to the external function would be slow and the DLL couldn't "remember" anything), or does it load the DLL one time and there is no manual way to control this (i.e. we can assume the DLL is loaded and we have no way to release the DLL ourself, the DLL could remember things like global variables in it set by the .NET program).
Thanks in advance,
Dominik
_outp(0x64, 0xAD);
and
__asm mov al, 0xAD __asm out 0x64, al
do the same... but what do they do??
(doesn't work on NT)
|
|
|
|
|
The runtime loads the DLLs when the P/Invoke method is called. The proc address is found only once, which implies that the DLL remains loaded. I do a lot of interop (one could say it's my forte') and maintaining state has never been a problem.
Note that if you want to load and unload native DLLs you can always P/Invoke LoadLibrary(Ex) , GetProcAddress , and FreeLibrary .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hi,
when i do this:
string unicodeString = "This string contains the unicode character";
// Create two different encodings.
Encoding ascii = Encoding.ASCII;
Encoding unicode = Encoding.Unicode;
// Convert the string into a byte[].
byte[] unicodeBytes = unicode.GetBytes(unicodeString);
// Perform the conversion from one encoding to the other.
byte[] asciiBytes = Encoding.Convert(unicode, ascii, unicodeBytes);
and I try to convert a Hebrew string to ascii I got in the asciiBytes
the number 69 (equals to '?')
but in english it's work just fine.
What is the problem?
Thank you in advanced,
Eran.
|
|
|
|
|
You have to use the Hebrew codepage. See Encoding.GetEncoding .
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hello,
What I want to do is have a background image on my tabpage that does not move when the tabpage's scrollbar is moved.
Right now what I am doing is in the tabpage's paint method I am drawing the bitmap:
pe.Graphics.DrawImage(bmpTabBack,0,0);
I have overriden WndProc and when I get a WM_VSCROLL message I do:
Invalidate(false);<br />
Update();
This does keep the background image in one place but there is some flickering if you move the scrollbar up/down really fast.
Is there another method that I can use to make it so that the background image never moves and there is no flickering?
Thanx for the help,
-Flack
|
|
|
|
|
You could try enabling double-buffering so that the image is drawn to a compatible off-screen bitmap and then swapped to the screen's device context. To do this, see the ControlStyles enumeration, specifically the DoubleBuffer member. Use Control.SetStyle in your contructor to enable the three necessary styles along with true as the second parameter. This should help.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Hey All,
I am looking for some advice. I am pretty new to C# with a little experience making form based windows applications that are pretty quick and dirty just to get them done (such as my psudeo translator that allows me to replace characters in a resource file with Japanese characters to test localization of products.) However I am trying to do something new which is to create an application that has multiple forms, however I am not a big fan of having several different windows open on the screen free floating when they could be wrapped in a single window. I would like a cleaner solution than closing one window with form1 and opening a new window with form2 on it.
After looking at my options I came up with several ways of doing this:
1) Instead of creating several forms, just use several panels that hide the controls based on a view switch. This seems cumbersome to do with the form designer, but seems possible if I hand write everything. I think this would work the way I want it to. Also I am a little afraid that this might mean all the code is in the form1 class which would be hard to maintain.
2) Not sure if I could just create a custom control that mimics the functionality that I looking for and then hide and show these based on views. This would allow me to create different elements of each control and re-use some other external controls such as listviews for displaying drag and drop elements. Not sure what I just said or if I can accurately express what I was thinking.
3) Rewrite the MFC Formview architecture in C#. Sounds like a lot of work but it may be worth it in the long run. Then I can feel like I accomplished something. Just not sure that it would be any better than a simplier idea though....
Any advice from someone that knows a bit more... Am I missing something (other than my own sanity)?
Thanks,
Brian
If you start a fire for a man, he will be warm for a day. If you start that same man on fire, he will be warm for the rest of his life.
|
|
|
|
|
If you just don't want for your other forms to show in task bar, then set ShowInTaskbar property to false.
Q:What does the derived class in C# tell to it's parent?
A:All your base are belong to us!
|
|
|
|
|
Thanks for the suggestion.
My biggest problem with multiple windows is the flow and controlling the user experience. I know that I often get frustrated with the amount of free floating windows in some applications and trying to get them positioned just right so I feel like I can use them. I don't mind dockable windows but only within the context of the view. I also don't really like a completely dialog based application with a stagnant main window. Sometimes I wish I was just plain satisfied but no I have to have this critical streak in me....
If I show and hide each window but it is not in the task bar then how do they get back to the correct window? I guess I could mimic switching by having the previous form size the next form to its own size, then tell the previous form to hide itself (both minimized and remove itself the taskbar). It seems lit a bit of a hack but I think it might work. Not sure what the performance would be like.. Is there a way of sharing menus and toolbars between forms?
Any other ideas or opinions?
Thanks,
Brian
If you start a fire for a man, he will be warm for a day. If you start that same man on fire, he will be warm for the rest of his life.
|
|
|
|
|
I've written an export type C# application which formats and saves an excel spreadsheet. I added a reference to excel using the .net ide and all seems to work fine on my pc. When I copy the exe (including Excel, VBIDE and Office dlls) to the target pc the application seems to run (and create the target file), but the file it creates contains about 10 characters, all of which are jibberish. The target PC contains the same version of excel as mine, does anyone knowwhat I need to do to make the app work? Do I need to register any of the dlls?
Thanks for any help
Jason
|
|
|
|
|
No, you do not need to register the DLLs (the only assemblies you would register are those that contain CCWs, or COM-Callable Wrappers - the interop assemblies you're using are RCW, or Runtime-Callable Wrappers, to COM servers already registered).
Instead of create the interop assemblies yourself, use the PIAs (Primary Interop Assemblies) from Microsoft - the official assemblies created by them. You can download them for Office XP (just search for Office PIAs on http://msdn.microsoft.com[^]) or install them with Office 2003 Professional as ".NET Framework Support" or something like that.
Make sure that these assemblies are either deployed to the same directory as the assemblies you've created (and pay attention to code access security policies if they're not running on the local machine), or install them into the GAC (Global Assembly Cache) using gacutil.exe, ngen.exe (also pre-JITs the IL), drag and drop them to %WINDIR%\assembly, or using an installer like Windows Installer (for which VS.NET has basic installer projects).
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
Thanks for the advice, I just about managed to follow it all! (maybe one day i'll increase from newbie status!) The version of office I am using is 2000, so I can't go down the PIA route. I think i'll create an installer for the app as I don't have direct access to the machine, it's an end user performing the install.
|
|
|
|
|
ok i have 2 question how do i select a printer and second how to i print a .tiff file code somebody give me a code sample
thanks
chad
|
|
|
|
|
cmarmr wrote:
how do i select a printer
PrintDocument.PrinterSettings
cmarmr wrote:
how to i print a .tiff file code
See PrintDocument class in MSDN and there is an exmaple of printing there. In the PrintPage event use DrawImage instead of DrawString in that example.
Mazy
"I think that only daring speculation can lead us further and not accumulation of facts." - Albert Einstein
|
|
|
|
|
I was wondering what would be the best way to encrypt text data to a file. At the moment, I am basically serializing my class object that holds all the data, and storing the data via a BinaryFormatter (to a text file).
I was just wondering if there would be a better way to do this?
Here is my code:
Stream stream = File.Open( filePathString, FileMode.Create );
BinaryFormatter bformatter = new BinaryFormatter();
bformatter.Serialize(stream, Organizer.activeProfile); //activeProfile is my object
stream.Close();
Thanks in advance,
Jon
|
|
|
|
|
If you want to encrypt it, use the System.Security.Cryptography classes. You can chain whatever encryption method you want with the ToBase64Transform class to output base64-encoded data (most common) to a text file. Read the class documentation for various classes. There's a lot of example code.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
I am involved in the redesign of a large project which is expected to take approx 5 years to complete. I need to find out (if possible) where MS GUI designs are going, i.e. what Microsoft intend to do with their GUI's will they be sticking with Office 2003 theme?
Can someone guide me to a suitable URL where I can read up on where MS are going with their GUI designs.
|
|
|
|
|
The Office 2003 scheme? Every Office has introduced a new scheme which has pretty much set the standard for products until the next Office is released. With a release schedule 5 years away (at least), basing your product on Office is probably not a good idea. Just go with the typical flat style which is still the basic scheme of the newer variants.
Another option is to use a third-party library that keeps up-to-date with the Office scheme. Even before the new Office comes out, the company should update their UI and release new assemblies, which - if they are backward compatible - you could simply add a publisher policy to the GAC or using binding redirection in your app's .config file to use the new versions even without recompiling (if it's already deployed, for example, and isn't ready for a rebuild). That'd probably be your best option, unless you want to maintain your own UI toolkit in a similar fashion. Just make it as abstract as possible, perhaps even supporting whatever theme a user wants.
Microsoft MVP, Visual C#
My Articles
|
|
|
|
|
|
5 years down the road we may very well be using Avalon instead of System.Windows.Forms. That would pretty much throw away all your UI work.
---------------------------
He who knows that enough is enough will always have enough.
-Lao Tsu
|
|
|
|
|
Longhorn and Avalon[^] is the way MS are going. However they still haven't released any information about the actual look and feel of the new presentation layer.
It might be worth looking into using something like MyXaml[^] as this will help keep your presentation layer seperate from the rest of your application logic. Allowing you to change the UI without having to recompile your application code.
Michael
But you know when the truth is told,
That you can get what you want or you can just get old,
Your're going to kick off before you even get halfway through.
When will you realise... Vienna waits for you? - "The Stranger," Billy Joel
|
|
|
|