.net

Overloading Operators in C++, exporting and Importing then in VB.NET

Howdy all, I have a weird situation. I have a C++ code that overloads the +,-,* operators and exports them in a .DLL file. Now, I want to import those overloaded operators from within VB.NET code. So it should be like this: <DllImport("StructDLL.dll")> Public Shared Function Operator +(ByVal a1 As A, ByVal a2 As A) As A End Function ...

Dependency injection in .Net without virtual method calls?

I've been thinking about whether it's possible to apply the DI pattern without incurring the cost of virtual method calls (which according to experiments I did can be up to 4 times slower than non-virtual calls). The first idea I had was to do dependency injection via generics: sealed class ComponentA<TComponentB, TComponentC> : ICompon...

How can I get an executable's icon in .Net?

I'm looking to get an executable's application icon in .Net. How can I do this? I'm thinking I'll have to query its resources, some how, but I'm open to any general-case solution. ...

Visual Studio 2008 - re-prompt to migrate web app from .NET 2.0 to .NET 3.5

If you have already been prompted to migrate your solution from .NET 2.0 to .NET 3.5 and you responded "No" at the time, how do you get Visual Studio 2008 to re-prompt you with this question? Sorry, if there is a real simple solution to this one. ...

Binding to the selected item in an ItemsControl

I created a custom ComboBox as follows: (note, code is not correct but you should get the general idea.) The ComboBox contains 2 dependency properties which matter: TitleText and DescriptionText. <Grid> <TextBlock x:Name="Title"/> <Grid x:Name="CBG"> <ToggleButton/> <ContentPresenter/> <Popup/> </Grid> </Grid> I want...

How to work with Oracle, .Net, Winform, Windows Vista and XP

Hi, I have an application that is a WinForm in C# that work with Oracle as database. I'm developing in Visual Studio 2008 in Vista, with Vista Oracle Client (10.2.0) and ODP.Net (2.102.2.20). The problem is that some users od this application work with Windows XP, so the Client isn't the same and the application says that it's "need" t...

WinForms databind to collection property (such as count)

I want to databind to a collection property, such as Count. in general, when I data bind I specify data member for the object property in the collection, not for the actual properties collection itself exposes. for example, I have a list of custom objects. I show them in datagridview. but I also want to show their total count using a s...

What files should I include in a Visual Studio 2008 project I wish to share?

I want to create a Visual Studio 2008 project which contains some example code of how to use an API and then make the project available to download so others can just double-click the project, see the code and run the examples without making any changes. What files (e.g. .suo, .sln, bin & obj folders?) do I need to include so that peopl...

Tracking the process of a singleton process in a web application

When I hit the run button (in my Default.aspx), a process starts (this process contacts a webservice to get some files, etc). How do I: Ensure that only a single process is running at a time (i.e. if I refresh the browser, I don't want to start the process a second time) Track progress - there are 4 points of the process (at 25%, 50%,...

.Net xsd.exe tool doesn't generate all types

For some reason, MS .Net (v3.5) tool - xsd.exe doesn't generate types when they are not used inside any element. e.g. XSD File (I threw in the complex element to avoid this warning - "Warning: cannot generate classes because no top-level elements with complex type were found."): <?xml version="1.0" encoding="utf-8"?> <xs:schema target...

How can I make my Visual Studio examples run on different versions?

Hi, I want to produce some examples of use of an API that people can download and run. I want to package the examples as Visual Studio projects that people can just double-click and run the examples. I run VS 2008, what steps will I need to take to make the examples able to run in VS 2005 and possibly later versions such as 2010? Are...

Is there a way to programmatically get the source file and line number of an arbitrary MemberInfo?

I am writing a code analysis tool that uses reflection to validate a particular code base. When I encounter a type or member of interest I would like to load the symbols and extract the source file and line number where the member or type is defined. Is this possible? If so, how? class SourceInfo { public static SourceInfo GetFrom(M...

What is the optimum timer interval? .NET Windows Service

I have a .NET Windows Service that has a timer with interval set to 10 seconds. Every 10 seconds, it queries the database for any work to be done, picks up top 3 work items and processes them. The time taken to process each work item would depend on the user. It might range from a few seconds to several minutes. I feel that 10 seconds ...

How to digitally sign PDF files with smartcards in .NET?

I have a smartcard that stores my digital certificate. When I plug it into my PC, the certificate shows up at the Windows certificate store, under IE > Tools > Internet Options > Content > Certificates. So... How can I use such certificate to sign a PDF file in .NET? ...

Entity Framework - Correct way to check for single records before using them

To get a LIST of records I normally do something along the lines of: var efCompany = from a in _dbRiv.Company where a.CompanyId == companyFeedInfo.CompanyId select a; To get a single record, when I know I am using the PK to retrieve it, I use something like: var efCompany = (from a in _dbRiv.Company where a.CompanyId == companyFeedIn...

Can i add a workflow as an activity to another workflow?

I would like to create compositions of workflows in WF (3.5). Is it possible to directly use a workflow as an activity inside another workflow? I don't want to use the InvokeWorkFlowActivity, since it executes the workflow asynchronously. ...

Need a way to center a TextBox under a Canvas in WPF Designer

I'm new at using the WPF Designer in VS2008 and I know very little about it right now. I'm trying to learn via experimentation. Below is my XAML (generated mostly by VS): <Grid> <Grid.RowDefinitions> <RowDefinition Height="478" /> <RowDefinition Height="64*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions>...

How do I create WCF EndPointBehaviors in Code rather than the configuration?

I have the following Xml Configuration <system.serviceModel> <services> <service name="MyService.MyServiceREST" behaviorConfiguration="MyServiceTypeBehaviors"> <host> <baseAddresses> <add baseAddress="http://localhost:1234/MyService/xml"/&gt; </baseAddresses> ...

Issues to consider when choosing data access technologies?

There were times when we had to choose between 2 or 3 technologies/strategies to develop modules. Now for every small or large component/module/project, we have almost uncountable options. It might be easy for those with years of experience, but not for those who are new to programming, say less than a year. I get frustrated sometimes ...

Any advice regarding a hexagonal architecture with serialization as the primary metaphor?

I've got the opportunity to rewrite the core of an internally-developed application that my employer uses for document control. My "core" requirements list goes something like this: Make it easier to import/export to various formats (collection of files + fairly extensive metadata being the common factor) Make it easier to add new fie...