.net

How do I call .NET code (C#/vb.net) from vbScript?

I imagine I can compile a C# DLL and then expose it as a COM object so that it can be CreateObject'd from VBscript. I'm just not sure the steps involved in doing this... ...

.NET: Is there a String.Format form for inserting the value of an object property into a string?

I think the direct answer to the question is 'No' but I'm hoping that someone has written a real simple library to do this (or I can do it...ugh...) Let me demonstrate what I am looking for with an example. Suppose I had the following: class Person { string Name {get; set;} int NumberOfCats {get; set;} DateTime TimeTheyWillDie {g...

How do I call a Pb generated native Win32 dll from .Net? Or from anywhere else?!

I have been trying to link to Pb (11.5) generated native Win32 dlls: both from a different Pb app and from a .net (2.0) app. I am aware that registered COM objects are visible to Pb. What I want to do is have Pb (running 11.5 Enterprise) call functions in a native Win32 dll--not COM. I also want to go the other way: I want a Win32 exe...

Book Recommendation for Winforms Design & Programming

I'm looking for a book or a good resource about the following subjects : Best Practices on Windows Forms design (such best way to design GUIs -using anchors-, using default fonts, avoiding changing colours etc.) Advice about common GUI pitfalls (usability, accessibility, compatibility) Basically I've got a WinForms application and I...

W2 Electronic File library or code examples for .NET?

Does anybody know if there is a code example on how to create an electronic W2 file in .NET? I did a Google search but only received results with W2 jobs, not W2 code examples. ...

How can I determine how much memory my .NET program is using?

It seems to be often said that Task Manager does not provide an accurate indication of how much memory is in use by a process. If this is indeed the case, what's the easiest way to find these things out? I'd like to know: Total Memory in use (whether in RAM or paged or whatever) Total RAM in use (running in a situation where the mach...

How to reload a 3rd party DLL that crashes often

I'm using a 3rd party DLL written in unmanaged C++ that controls some hardware we have. Unfortunately this DLL crashes now and then and I've been tasked to make it "reload" automagically. I'm not too sure about how to proceed to get best results. My project uses C++.Net 2.0 (2005). I'm wrapping the 3rd party stuff in a separate DLL. I'...

Using a Regex to find specifically formatted fields

In an application I'm developing, someone thought it would be ok idea to include commas in the values of a csv file. So what I'm trying to do select these values and then strip the commas out of these values. But the Regex I've built won't match to anything. The Regex pattern is: .*,\"<money>(.+,.+)\",?.* And the sort of values I'm ...

Do you need to unit test a constructor.

Do you need to unit test constructors, say I have a ctor like this, IMapinfoWrapper wrapper; public SystemInfo(IMapinfoWrapper mapinfoWrapper) { this.wrapper = mapinfoWrapper; } Do I need to write a unit test for this ctor? I don't have any getters for the wrapper variable, so I don't need t...

How can I attach a .NET delegate to an mshtml event?

I'm working on an extension (BHO) for Internet Explorer, and having trouble attaching a .NET delegate to the mshtml objects to catch DOM events. I've tried using the events published by the IHTMLElementEvents2_Event, ... interfaces, and that works, but only if I specify the correct type for the DOM element whose events I want to catch. ...

Casting null as an object?

I came across this code today AsyncInvoke(OnTimeMessageTimer, (object)null, (ElapsedEventArgs)null); Is there anything wrong with it or no? ...

C# "internal" access modifier when doing unit testing

I'm new in unit testing and I'm trying to figure out if I should start using more of 'internal' access modifier. I know that if we use 'internal' and set the assembly variable 'InternalsVisibleTo', we can test functions that we don't want to declare public from the testing project. This makes me think that I should just always use 'inte...

How would you refactor this conditional to use polymorphism?

I just finished watching the Google clean code video on YouTube (see link, first article) about removing if statements from your code and using polymorphism instead. After watching the video I had a look at some code that I was writing before watching the video and noticed some places where I could use this method, mainly places where...

Typed dataset not updating on column addition

I have a datagridview that I'm using in Visual Studio 2008 for a winforms app. The datagridview is bound to a typed dataset. I added a few columns to the table referenced from the typed dataset. So, i open the typed dataset and reconfigured the datatable to show the new columns. When I do a preview, the columns are there. However, when i...

how sqlConnection hides the password of the connection string

Hi all, I'm making a component which uses some data to connect to a database, this data includes user id and password, it store those values in private variables but any programmer can see the value in the debugger after the initialization, so I'm wondering how the SqlConnection does to hide that value, when I see the value of the prope...

Using environment variables for .config file in .NET

I need to specify path to dlls referenced by assembly in .config file. Problem is that path can be found in env. variable. Is it possible to use some sort of %DLLPATH% macro in .config file? ...

How to install a windows service programmatically in C#?

Hi, I have 3 projects in my VS solution. 1 is a web app, the other is a windows service and the last one a setup project for my web app. What i want is by the end of the installation of the web app in my setup project, within my custom action to try and install my windows service given that i have the location of the assembly by then....

When does CLR say that an object has a finalizer ?

I know that in C#, if you write ~MyClass(), this basically translates to override System.Object.Finalize(). So, whether you write the destructor or not, every type in CLR will have a Finalize() method in it (of System.Object at least). 1] So, does it mean that, every object, by default, has a finalizer ? 2] What is the basis for the CL...

Linq to sql error with identitiy increment field

I've just started to use linq to sql and have run into a problem with inserting a record with an auto incrementing field. I have created a new instance of a company object defined by linq. it has initialised an auto incrementing field 'companyID' to 0. InsertOnSubmit() fails with the following invalidOperationException. Incorrect au...

About consistensy in the powershell scripting language, using .NET types

If I want to create a .NET object in the powershell I write something like the following: [System.Reflection.Assembly]::LoadWithPartialName("System.Xml") | out-null" $doc = new-object -typename System.Xml.XmlDocument" If I want to call a static .Net method I use a command similar to the following line: $path = [System.String]::Format...