.net

How can I access an explicitly implemented method using reflection?

Usually, I access a method in reflection like this: class Foo { public void M () { var m = this.GetType ().GetMethod ("M"); m.Invoke(this, new object[] {}); // notice the pun } } However, this fails when M is an explicit implementation: class Foo : SomeBase { void SomeBase.M () { var m = this.GetTy...

Data processing at the client or server

Hello everyone, I need your suggest about data processing. My server is a data server (using SQL Server 2005). And my client will get data from the server, and display them on windows. Server and client is on internet (not LAN). So, time to get client is depended on the data's size and internet speed. Assume: the SQL Server has a tabl...

.NET/COM interoperability: user control

Hi, I create a .net custom usercontrol to be used in COM through Borland C++ Builder. 1) i implement an explicit interface and decorate it with some attributes (ComVisibleAttribute, GuidAttribute and InterfaceTypeAttribute). This interface has 3 properties just to try, each property has a DispIdAttribute. `namespace SimpleCOMServer{ [...

How to call native exe function(visual basic 6.0) From .Net (C#)?

Hi, We have an exe file produced by visual basic 6.0(unmanaged exe) and a .net exe written with c#. How can I call a function in unmanaged exe(visual basic) from clr exe? Thanks. ...

Using IErrorHandler and TCP Message Security causes a timeout

I have a WCF service with a custom IServiceBehavior attached used to return a specific fault on the client side. When I enable this code with TCP Message Security I receive a service timeout. Below you can see the full client and server code to reproduce the error. Server code: using System; using System.Collections.Generic; using Sy...

Strange COM interop exception 0x80005000 using System.DirectoryServices.AccountManagement libraries

Hi, I'm trying to write something that (amongst other things) adds a user to an AD group - using VS2010, .Net4 and the library facilities in System.DirectoryServices.AccountManagement. I've gotten a user and group by code like the sample below, and this works for other operations like enabling or disabling accounts. group = System.Dir...

Avoiding .Net CAS Policy changes for FullTrust?

I've got a .Net assembly served from a (non-IIS) website (invoked ActiveX-style with an OBJECT tag) that needs FullTrust permissions. <OBJECT id="myControl1" name="myControl1" classid="MyControl.dll#MyControl.myControl"> I can do this by modifying the CAS policy on each client machine like this: caspol -machine -quiet -addgroup Trust...

Type casting error and constructor

I have two classes public class A { public A() { } } public class B:A { public B() { } } and it the code in Main is as follows A oa = new B(); B ob = new A(); Here line 1 compiles successfully while line 2 displays typecasting error. Why this happens. ...

In .NET can a class have virtual constructor?

Can a class have virtual constructor?? If yes, why it is required? ...

ASP.NET MVC2 User Profiles

Hi. What is the easiest way to create users with associated profiles in MVC2? Is there any library already having such functionality? Thanks in advance. ...

.NET. How to hack OpenFileDialog?

Possible Duplicate: changing button text in OpenFileDialog in C#.net Have a good day, Is there a way to override Open button in .NET OpenFileDialog? I need to Change the button text and override OnClick event. If this is not possible can I put a custom button over the Open button (but at the most top X order)? -- BR Murat...

Does WCF execute the operations in a Singleton WCF service in the same thread?

I've service which is marked with the ServiceBehavior attribute [ServiceBehavior(InstanceContextMode=InstanceContextMode.Single, ConcurrencyMode = ConcurrencyMode.Multiple)] Is there any chance for the operations in this service to be executed by same thread? I'm storing an important data in ThreadLocal variable, which is to be us...

dispatcher timer for sending periodic data

Hi I want to send some kind of hearbeat at every configured time interval. I want to use dispatcher timer to send it. Main() { create dispatcher timer; } void dispacthertimertick() { // send heartbeat } How do i keep the main thread alive? Regards Raju ...

How to use transaction on a .DBF file using Odbc?

Hi I have a problem here using .dbf files. I can make CRUD operations but i get an exception when i try to use transactions. I am doing like this: public void AddRolesToUser(string user, string[] roles) { using (OdbcConnection connection = new OdbcConnection(ConnectionString)) { OdbcCommand command = ...

How to convert Expression<Func<T, TProperty>> to Expression<Func<T, TNewProperty>>

The following is working, but my Body.NodeType changes to Convert, instead of MemberAccess which is a problem when getting ModelMetadata.FromLambdaExpression: private Expression<Func<TModel, TNewProperty>> ConvertExpression<TProperty, TNewProperty>(Expression<Func<TModel, TProperty>> expression) { Exression converted = Expression.Co...

How can I embed a Visio 2007 editing control in my C# (.Net 3.5) application?

I would like to embed a Visio editing interface in my C# form. The best instructions I have found so far are from here: http://msdn.microsoft.com/en-us/magazine/cc164043.aspx but they are outdated. The biggest problem I am having is trying to determine which control I actually need to add to my toolbox so I can drag and drop it to my for...

Can a Windows service running under Local System create new files on the computer it is running on?

I have created a Windows Service that has a function that creates a new file. It is running under "Local System account" with "Allow service to interact with desktop" set to true. When running under this account can files be created locally? I can't debug this to get the exact error as it is running in a Lab Manager environment that h...

Compiling C to use the CLR

Possible Duplicate: Compiling C code for .NET I have a bunch of C source code and I want to compile it so it uses the .NET framework. I downloaded Microsoft Visual C++ and chose new CLR project. I then added all my C code, and I tried to compile the files. It said cl : Command line error D8045: cannot compile C file '..\..\...

Write Int array to Stream in .NET

Hi, what's the best way to write the binary representation of an int array (Int32[]) to a Stream? Stream.Write only accepts byte[] as source and I would like to avoid converting/copying the array to an byte[] (array but instead streaming directly from the 'original location'). In a more system-oriented language (a.k.a. C++) I would s...

c# string performance - what is faster to compare, string text or string length

hey guys i have to read a huge xml file which consists of over 3 million records and over 10 million nested elements naturally i am using xmltextreader and have got my parsing time down to about 40 seconds from earlier 90 seconds using multiple optimization tricks and tips but i want to further save processing time as much as i can hen...