Answer Questions
Anders Wallin Interop and security
I've got a customer site where some C# 2.0 assemblies are being used via a COM interop wrapper which is called from a Centura SQLWindows app. Never mind the fact that it worked last Wednesday, when I was there, or that it works on all my other customers' sites. On this one site, since then, it has developed issues. First of all, it threw an exception saying "That assembly does not allow partially trusted callers." So I added the AllowPartiallyTrustedCallers attribute to all the assemblies referenced by the Interop wrapper. Now, it's throwing an exception saying "Request for the permission of type 'System.Data.SqlClient.SqlClientPermission etc etc' failed." All the assemblies have been installed to a folder on the C: ...Show All
Shaantu Reading regional settings
I create automatic file names with current date and time, but I need to replace date and time separator characters with underscore ("_"). How can I get the "Date" and "Time" separators set by the user in Regional Settings in Control Panel Thanks, Mustafa use this: Thread .CurrentThread.CurrentCulture.DateTimeFormat.DateSeparator ...Show All
re infecta Running native code on C#
Hello, I know the basic things how to run native code dll's with C#, bus I have harder case. The function which is in native dll requires such parameters as structures and void * pointers. I have tried to use managed structures and objects as pointers, but nothig have worked. So how I can pass structures and void* pointers to unmanaged native functions Thanks in advance. Best regards, alpha Hello, Thanks for answer. I will try to use this and see how it works. Best regards, alpha Hello, Thank you for answering. So I'll try to show all C/C++ code that is used in calling: 1. Function itself (from *.h file) BOOL WINAPI DMConnectA( LPCSTR lp ...Show All
martin kaldma How can I share my custom user settings (ApplicationSettingsBase) with several objects?
In my program I have several classes: WebServer EmailClient TelnetClient ...and they all use configurable data which I have in a class called "GNotifyUserSettings" (which is a descendant of ApplicationSettingsBase). Do I need to create a GNotifyUserSettings object in every class I want to use custom settings in ...or should I pass in an object reference to the user settings object to every class Neither method seems very clean. What I'd really like is a "global object" that every class can access... (and it must be thread-safe) Sorry about taking a bit to get back to you on this... When I suggested making your class instance static I was not referring to the class defi ...Show All
leonlai Subtracting Times with Date
I thought this might have been a simple task...I need to subtract 4 hours from the current datetime that is input. The datetime format is mm/dd/yyyy hh:mm and the hours are a 24 hour clock. After it's input, I then take and parse this string into a strDate array and strTime array by doing args[0].split('/') and args[1].split(':'). After this is where I try to subtract the 4 hours, but there's a whole lot to account for as in if the hour is 1, you'd have to go to the previous day and if the day is the first day of the month, going back one day would take you back another month, etc. Is there an easier way to do this The month is really what's throwing me. Thanks in advance for the help! ...Show All
sandeep srivastava why multiple inheritance of classes in not supported in C#?
Multiple inheritance is not supported in C# but it can be achieved using interfaces is fine. But can you explain why multiple inheritance of classes in not supported in C# Put simply it isn't in because it hasn't been designed into the language. Are you saying that you would like it That's a different question and I think the majority of people wouldn't want it. Anders once said about Delphi that he didn't put it in because it would slow down the speed of the compiler. Whatever, it's of no real use, so most people woudn't want it. Other writers has shown to you some good points, why there is't multiple inheritance of classes. I add, that it is roughly achieved by inheriting from multiple interfaces, what is supported by C#. ...Show All
Marcos Torres Sending message to dialog form
How can I change text in TexBox of dialog window IIRC you can set the text of a textbox using the WM_SETTEXT message. The problem is you cannot send the message to Process.MainWindowHandle (I think it would actually change the title of the dialog). You must find the window handle of the control you intend to modify using the FindWindowEx API. You will need to find a control, child of Process.MainWindowHandle, that is of class "EDIT". If your dialog has more than one TextBox, you will have to call FindWindowEx several times, changing the hwndChildAfter parameter. Note: your dialog might use different classes for its controls. It's always a good idea to inspect the dialog first using Spy++ to be on the safe side. HTH -- ...Show All
Janne_K Disable the (red x) button on form
Hi all, 1. I ran into a problem trying to disable the (red x) button on the dialog box. for example, on the dialog it has Minimize and Maximize buttons, I can set that to false to disable it, but I can't set the close (red x) button. Please help me how to do that. thx 2. I ran into another problem, when I run my C# program and I have a main dialog box and also a popup dialog box when a button is clicked from the main dialog box. Some how it shows on the taskbar two (like two programs are running). I only want it to show just one not two. refer to the image ( http://www.esnips.com/imageable/large/f12fbc79-83ed-470d-832a-2a105d493d5e ) vshost.exe. Any help would be appreciated and I'm using C# Express 2005 Jason Hi ...Show All
gareth andrew lewis HELP - Problems using SendKeys class
Hi, I am developing an application that uses SendKeys to control a game. But the problem is that, till now, of all the games i hav tried, it can work only on BricksFix version 1.62. Can anyone pls tel me y it is not workin on other games. I tried a lot of games, but it is not workin, but wen i try on BricksFix its workin. Also if possible, pls give me a list of games which i can control using SendKeys. Thanx Most games would use DirectInput to obtain the keyboard status. SendKeys can only work if a program obtains it input from a message loop. im afraid there is no way we can provide you a list of games/applications that sendkeys will work with. Most likely, it could be the ap ...Show All
charles C Static Class Overhead
Hi, We were doing some refactoring here and had a discussion concerning static classes. Basically we have a set of classes with a bunch of methods in them that refer to strings. Now I have recommended that all strings should be defined as constants at the top of each class so that if a string needs to change we only change it in one place and not have to go through every method finding every instance of it. So basic good practice. Now with C# 2 came static classes. So the debate is to whether we should drop the constant strings out into a seperate static class and then refer to them in the method like a property of the static: i.e string myVariable = MyStaticClass.MYSTRING; as opposed to string myVariable = MYSTRING; W ...Show All
Tyrael Tong Something like the VB Iif statement in C#?
I'm looking for something like the Iif statement in C#. Some idea Regards. Thanks so much. Regards. C# has what is known as the "tertiary operator", which works like this: booleanExpression trueValue : falseValue ; In practise, this is used like this: int count = GetItemCount(); // Change display text depending on count string itemText = count > 1 "items" : "item"; Console.WriteLine("Found {0} {1}", count, itemText); ...Show All
AdrianGodong Check to see if Directory is being written to
Is there a way to check to see wether or not a directory is having data currently written to it Thanks. Can you elaborate your question please Best Regards, Thats what I was pretty much doing. I was catching the exception if the file was not fully written, skipping it and getting to it later. Then I checked for more files after I was done dealing with the files that were fully written. I just figured if I could check for the directory being written too, I could save myself some code. Thanks all. What if you write a file with a different extension in the directory I assume the writing of the file takes a undefined time to complete. If your write action is finish ...Show All
Preeteesh How to create variables and configuration settings for C# Windows Project
I need to store configuration details like Database Connection String, and other config details in a single location so that I can access it from any .cs file of the prj. How is it possible Thru some particular xml file or a text file PLZ reply asap as its urgent Sounds like this may be a task for the a User Settings action . The settings file, which is written in Xml, is used for such purposes like reading in a value, either for the user or the application .... See Using Settings in C# . / Using My.Settings in Visual Basic 2005 This feature is not there in .Net 2003. Is there any other way in .Net 2003 you can use the App.Config file. Right cl ...Show All
aspencergb Is it possible to change Font.Size in tabPages?
I got an error that this property is readOnly. Is it possible to change the font size in a tabPage It is very inconvenient to have just one size and it is very large as it is. Thanks. Nope, it does not work. I also tried to define the font via System.Drawning namespace like: Font fnt = new System . Drawing . Font ( "Microsoft Sans Serif" , 7.8F , System . Drawing . FontStyle . Bold , System . Drawing . GraphicsUnit . Point , (( byte )( 0 )) ); tb1 . Font = fnt ; It take the statements but the font remains the same. Alas. Thanks. Thank you, Ken. I just tried it. Amazingly it did not do a thing. It did not change the size at all. I put the size down to 9 because I need really sm ...Show All
Chopaka How to send data to a field in explorer?
Hello, I am building an application that works alongside explorer. The application generates some data that I then need to enter into som text fields on an explorer page. The application itself is currently in c# but this element could be rewritten in a different language. I am currently using Sendkeys but this relies on the windo having the focus, which I can;t guarentee, so I woudl like to find a way of sending data directly to a field. Any advice or hellp woudl be greatly appreciated. Steve You can use webbrowser control in your application and navigate it to that page. Then you can loop trough form elements of the page and insert values in text boxes. Maybe creating IE addin i ...Show All
