.net

How to simulate a member reference tracking variable in C++/CLI?

This is going to be a really goofy question but is it possible to do the following in C++/CLI? // C++/CLI public ref class Managed { public: array<double>^ m_data; Managed(array<double>^% data) : m_data(data) { } void bar(int x) { System::Array::Resize(m_data, x); ...

Can't add LINQ to SQL Classes in project upgraded to 3.5

I just upgraded a project to 3.5 SP1 and trying to add a LINQ to SQL class item to the project and can't as it doesn't appear in the Add Item list. Though if i create a new project in the same solution and try adding it the item (LINQ to SQL classes) is available and I can add it to the project. What do i have to do to be able to add L...

.NET: Is there a way to know which method the currently executing code is in? (for logging class)

Hi! I'm writing a logging class in C# and would like to add the method from which the log call was made. Doing this manually isn't too attractive. Is there a way to know which method the currently executing code is in? Thanks in advance for your awesomeness... Gregg EDIT: Using MethodBase... System.Reflection.MethodBase thisMethod ...

Implementing Nullable types in existing objects

I am upgrading an existing application that has implemented a home-brew Constants class in its business and datalayer objects. I want to replace this with Nullable types and do-away with the constants class, that looks like this, but with all non-nullable data types: class Constants { public static int nullInt { get { ...

Reference question: when are two objects equal?

I have a Vector class, and I was testing the following unit test (using nUnit). 1 Vector test1 = new Vector(new double[] { 6, 3, 4, 5 }); 2 Vector test2 = test1; 3 Assert.AreEqual(test1, test2, "Reference test"); 4 test2 = new Vector(new double[] { 3, 3, 4, 5 }); 5 Assert.AreEqual(test1, test2, "Reference test"); The first test i...

Is it possible to adorn a LINE OF CODE with a Conditional Attribute? (or something similar)

Hi! I plan to put a call to MethodBase.GetCurrentMethod() at the beginning of most methods (for informative logging), but since this would present a high overhead, it would be good if a conditional attribute could be used used like: #define LogMethodNames where... [Conditional("LogMethodNames")] was put above every line call GetCu...

Debugging Monitor.Enter, Monitor.Exit. How?

Is there anyway to see what objects have had locks placed on them in the visual studio IDE? ...

Packaging an excel addin

I have an automation addin for excel developed using C#. How do I package and distribute it ? Also when the addin is installed for the first time, I want a username and password check to pop for the first time. How can I go about doing this ? thanks ...

SqlCe odd results why? -- Same SQL, different results in different apps. Issue with

When I run this SQl in my mobile app I get zero rows. select * from inventory WHERE [ITEMNUM] LIKE 'PUMP%' AND [LOCATION] = 'GARAGE' When I run the same SQL in Query Analyzer 3.5 using the same database I get my expected one row. Why the difference? Here is the code I'm using in the mobile app: SqlCeCommand cmd = new SqlCeCommand(Q...

system.enterpriseservices.wrapper.dll error

We are getting the following error message when running one of our applications. Basically the application crashe. This is the error message I found in the event viewer EventType clr20r3, P1 winui.exe, P2 1.12.14.3979, P3 4b20fc8f, P4 system.enterpriseservices+system.enterpriseservices.wrapper.dll, P5 2.0.0.0, P6 471ebed4, P7 ba, P8 21,...

SmtpClient does not close session after sending message

I have a function that sends email using asp.net built in mail framework. I've included it below. public void SendMessage() { var message = new MailMessage(); var client = new SmtpClient(); // Get the Message Envelope Details this.LoadMessageDetailsFromFile(); // Process rules (if any): Rules engine not implemente...

How to get MAC address of client machine in c# and vb.net

How to get MAC address of client machine in c# and vb.net ...

Finding weekend days based on culture

Is there a way to find the days that constitute a weekend or workweek based on different cultures using the .NET framework? For example, some Muslim countries have a workweek from Sunday through Thursday. ...

ASP.NET MVC: Hidden field value does not get rendered using HtmlHelper.Hidden

Hey, Something pretty weird is happening with my app: I have the following property in my ViewModel: public int? StakeholderId { get; set; } It gets rendered in a partial view as follows: <%= Html.Hidden("StakeholderId", Model.StakeholderId) %> The form is submitted, and the relevant controller action generates an id and updates ...

what problems to expect when deploying net GUI application (on winxp/vista/7)

Hello all i like to build .net GUI application and to be able to deploy it on wide windows version as possible for non teachi persons , what should i be planning before i start to write the code like which minimum net version to compile which GUI to use ? include the .net framework in the installation or not ? to include net framework...

when & why to use delegates?

Hi everyone, I'm relatively new in c#, & I'm wondering when to use Delegates appropriately. they are widely used in events declaration , but when should I use them in my own code and why are they useful?, why not to use something else? I'm also wondering when I have to use delegates and I have no other alternative. Thx for the help. ...

Fluent; SessionSource or SessionFactory for creating sessions?

I'm using NHibernate + Fluent to handle the database in my application. So far I've been using a SessionSource to create my ISession objects. I'm a bit confused now about what comes from NHibernate or Fluent, and what I really should use for creating my sessions. ISession comes from NHibernate, and the SessionSource from Fluent. I crea...

.NET GUI control library for an (audio) player

I am going to build a player GUI control (a C# user control) for playing audio and other streamed data. The control should have at least the following controls: Pause/Continue/Forward/FastForward etc... as Buttons (with icons) Current position as some form of a slider Current time as digital clock Especially I am looking for a nice t...

Why does 'MSysNavPaneGroupCategories' show up in a .NET OleDbProvider initiated query to an MS Access 2K database when the criteria specifies "WHERE MSysObjects.Name NOT LIKE 'MSys*'"?

I want to list all tables and their row count, in an MS Access database, in a grid view. I am using a query as follows: SELECT MSysObjects.Name, CLng(DCount('*',[name])) AS RecordCount FROM MSysObjects WHERE (((MSysObjects.Type)=1) AND (MSysObjects.Name NOT LIKE 'MSys*')) ORDER BY MSysObjects.Name; In MS Access Query pane this works j...

XDocument memory usage problem

Hi, I have a small application that builds up a xml document using XDocument. However, after a while the app is using more than 1gb ram. So I was wondering if there is anyway to make XDocument use the disk instead of in-memory. For example by opening a StreamWriter and save it to a file on the go. Thank you in advance. ...