David N.4117's Q&A profile
.NET Development how to detect internet connection automatically
i use this code to detect the internet connection but i need a better idea to get a notification as soon as the PC looses the connection and it will be silly to keep this code in a timer.. [ DllImport ( "wininet.dll" )] private extern static bool InternetGetConnectedState( out int Description, int ReservedValue); public static bool IsConnectedToInternet() { int Desc; return InternetGetConnectedState( out Desc, 0); } Here is a little piece of managed code, but you still have to use a Timer to check poll it every time. You should create a little helper class that will raise the events: private bool IsNetworkConnected() { bool connected = SystemInformation. ...Show All
Visual Studio Tools for Office WinForms Object Error (Windows Vista & Office 2007)
System Config(s): Windows Vista Ultimate with Office Ent. 2007 Office 2007 PIAs VSTO 2005 SE (have also tried with original VSTO 2005) also tried on Windows XP with Office Ent. 2007 VSTO Solution: Word Template Document-Level Customization Basic test application that contains a custom Action Pane with a button. The click event of that button creates an instance of a custom WinForm control and adds that control to the ThisDocument Controls collection. Code Example CustomControl customControl = new CustomControl(); Globals.ThisDocument.Controls.Add(customControl, rng, 120, 80, customControl.Name); Problem: On Windows XP running Office 2007, this works fine. Under Windows Vista I am receiving the following error: The program used to crea ...Show All
Visual Studio 2008 (Pre-release) 3d Mesh Collision
I'm working on a simple game in WPF, and I would like to know when to meshes (ModelVisual3Ds) collide. For example, if a character shoots a rocket, I want to know if the rocket hits something. I thought that one of the HitTestResult classes may be the answer, but I'm not so sure. In v1, the WPF does not have a feature for general collision detection, but ray hit testing may be adequate for your scenario. The code to perform the hit test will look something like the below: VisualTreeHelper.HitTest( _mySceneRoot, /* filter = */ null, new HitTestResultCallback(HTResult), new RayHitTestParameters(_rocketPosition, _rocketDirection)); Your HitTestResultCallba ...Show All
Visual C# Adding new project in current project?
How do i add new c# project file to a current project so that when i click a button on the current project it will invoke the project added... can also anyone provide me with c# code on "BROWSE" .. so that i can choose directory on where i want to save my file... thanks ahmedilyas thanks alot, i really appreciate it, but the code above doesnt work instead i use this: this.txtFilename.Text = (theFolderBrowserDialog.SelectedPath); it does work, but i have this problem, how do i give a filename to it instead of SelectedPath alone, i want it to be like SelectedPath\filenamegiven , can i like after pressing OK , it popup a windows asking me to enter a fileName and then it will appears in the txtFilename as: SelectedPath\Filena ...Show All
SQL Server Nested filtering in Ad Hoc reports?
There are many business users in my office who would like an AD HOC reporting system. I am not in a position to install the entire suite and check it out myself. I have seen some presentations and i like the tool for the most part ...I have some questions if anyone can help.... 1. Can the user specify more than one condition in the filter. Like Name = X AND Address = Y AND Job = Z 2. Can the users sort on more than one column 3. Can the users group by on more than one column. Nested grouping ...Show All
Microsoft ISV Community Center Forums call addin's userform
I have creadted a .xla file, it have a userform in it. i have loaded the xla addin. now in my new spreadsheet, through vba maros can i display the userform which is in that .xla file any help or ideas on how can i achive such a thing would be appreciated nrupesh hi there, create a public method in your addin that displays the user form. You can then call this method using... Application.Run ("myAddin.xla!ShowForm") It's important that a) you check that the add in has been installed and b) that your addin does not have any spaces in it's filename, otherwise the Run() method won't be able to find it. Use the Addins("myAddin").Installed = True to determine if the Addin has been installed Hop ...Show All
SQL Server Table Valued Functions - yield return error
So I was creating a new table-valued function today which queries some data from a preexisting table. Since this is my first table-valued function, I decided to check out some of the examples and see what I can figure out. One particular example helped me out a bit until I ran into some data access issues... http://msdn2.microsoft.com/en-us/library/ms165054.aspx So I create my function: [ SqlFunction (DataAccess = DataAccessKind .Read,SystemDataAccess= SystemDataAccessKind .Read,FillRowMethodName = "FillMyRow" ,TableDefinition = "p1 int, p2 int"] public static IEnumerable getMyTable( ) { using ( SqlConnection conn = ....) { using ( Sql ...Show All
Visual Basic Stopping a function
Is it possible to stop the execution of all the later commands inside a function or sub For example: Private Sub pbxAbout_Click( ByVal sender As System.Object, ByVal e As System.EventArgs) Handles pbxAbout.Click If IsRunning() Then 'What goes in here End If ShowAboutPart() CleanNewPart() End Sub What could i replace the comment with in order to stop execution of ShowAboutPart() and CleanNewPart() That is, without putting an Else statement into the if statement, since more complex examples (that i didn't post here) it simply wouldn't be viable to do that. Hi, Yes if you want to stop further statements being processed then use>> EXIT SUB&n ...Show All
SQL Server Move .ndf file to a different drive
I have a several indexes on a filegroup that I would like to move to a different physical drive. I am aware of the sp_detach...sp_attach routine which allows moving the .mdf and .log files to a different location. How would I go about moving a .ndf file though TIA Thanks Simon...that worked! I just wasn't sure if that's how it was done. Needed some reassurance! And...I'll definitely consider giving my next DB a .simon extension! :) ...Show All
Windows Forms Window class name is not valid
When I create a new WindowsApplication project, add any control to the main form and run the project - I get the following exception on Application.Run(new Form1()); I am using VS 2005 beta2.050215-4400. This haven't happened until now. What went wrong Any help will be appreciated Gabriel The exception data follows: System.ComponentModel.Win32Exception was unhandled Message="Window class name is not valid." Source="System.Windows.Forms" ErrorCode=-2147467259 NativeErrorCode=1400 StackTrace: at System.Windows.Forms.NativeWindow.WindowClass.RegisterClass() at System.Windows.Forms.NativeWindow.WindowClass.Create(String className, In ...Show All
Visual Studio 2008 (Pre-release) Used of AddAutomationFocusChangedEventHandler in WPF application
When I used AddAutomationFocusChangedEventHandler function into a WPF Application, my application freeze. If I create another console executable just for using AddAutomationFocusChangedEventHandler, I have not problem. Example when I use WPF menu from my application, this application freeze. Have some people have problem with this function into WPF application Thanks. public ComponentAutomation() { ThreadStart threadDelegate = new ThreadStart(ThreadOfFocus); workerThread = new Thread(threadDelegate); workerThread.Start(); } public void ThreadOfFocus() { focusHandler = new AutomationFocusChangedEventHandler(OnFocusChange); Automation.AddAutomationFocusC ...Show All
SQL Server Query to another server
Hi, I'm trying to do a query from ine server to another, something like this: " SELECT * FROM FILESERVER . SharePointConnectingDB . dbo . vDepartmentsNames" where FILESERVER is the other SQL server name, SharePointConnectingDB is the the DB in the other server, etc. as a return i get the following error (in spanish becuse the server is in spanish): in El proveedor OLE DB "SQLNCLI" para el servidor vinculado "FILESERVER" devolvio el mensaje "Especificacion de autorizacion no valida". Msg 7399, Level 16, State 1, Line 1 El proveedor OLE DB "SQLNCLI" para el servidor vinculado "FILESERVER" informo de un error. Error de autenticacion. ...Show All
.NET Development Runtime Security Policy change failure
I tried to increase the Trust level for some managed applications. I used Control Panel, .NET framework 2.0 Configuration, Runtime Security Policy, Increase Assembly Trust. Then whatever application I select, i get the following error: System.Security.SecurityException: Impossible to generate hash for assembly, in System.Security.Policy.Hash.get_RawData()... Somebody can tell me how to overcome this problem Luigi Fonti ...Show All
Visual C# Activation validation of installed C# programs
I would like to have my program validate a user license each time their program runs. The database name, company name are needed for the program to run correctly so I would like to have them enter these and enter a hashed serial number I provide for them at purchase time. The program compares the serial number they enter with an internal algorithm. If it matches, then the program can use the entered database name and company name. I do plan on using a third party tool for obfuscation with string encryption. I would appreciate your thoughts/ideas about how this is usually implemented for reasonable security! you're correct in asking such questions, its a good challange for me, you and everyone. ...Show All
Visual Studio Cannot select a data source
When selecting the link Add project data source... , I get a message box titled "Wizard Form", with the following message: "An unexpected error has occurred." "Error message: Key not valid for use in specified state." It was working fine last week. What does this mean, and how do I correct it Please don't tell me that the product key is now invalid... I think I just figured out the problem. If you open up the Database Explorer (Ctrl+Alt+S) you'll probably find an old database connection that no longer exists. If you delete it you should be able to connect to DBs again. ...Show All
