Posts Tagged ‘microsoft’

how can i change enterprise library connection state

Monday, August 23rd, 2010

Hi there,

I am using Microsoft Enterprise Library for MS SQL. Enterprise Library automatically closes its connection, but I don’t want it to close. How can I keep open an Enterprise Library Connection?

Thanks a lot..

.NET thread safety

Monday, August 23rd, 2010

List.Add is an instance method. That means it’s not guaranteed to be thread-safe. What does this mean?

Possibility 1. That if two threads invoke .Add on different instances, there could be an unexpected result depending on the phase of the moon?

Possibility 2. That if two threads invoke .Add on the same instance, there could be an unexpected result depending on the phase of the moon and if the instances are different there is no potential problem.

Possibility 3. Microsoft doesn’t want people to use threading at all so they wrote .NET to be ambiguous.

Make a class in C++ form application global

Monday, August 23rd, 2010

I find myself stumnped by what should be a simple problem. How do you make a class (created in a seperate file) have global scope when using forms in Microsoft C++. I can declare, initalize, and use it in a textbox leave or keypress function but when I move to a button it is out of scope (the button and textbox have global scope, but I just am stumped by how they do it).
The problem is to make a clone of the class (object) and to do that it is advantageous to have the global scope.
I realize this is homework, and I am not asking for code, just point me in the right direction.
Thanks
DJ

.Net with Microsoft Speech Recognition Engine

Sunday, August 22nd, 2010

Hi,

Just out of interest, is there any good resource out there for programming .NET Application with some voice command, using the Microsoft Speech Recognition Engine?

If I can just get to writing a simple application which takes in a speech for few seconds and return a word that will be good enough. Of course it might not be that easy.

Thanks in advance.

How to prepare to the interview question “How would you test this function?”

Sunday, August 22nd, 2010

Hi folks!
Big companies like Microsoft often ask you to write some function (for example reverse all words in the statement) and then write test cases for it. What is the best way to prepare for writing such test cases?

How to use inline modifiers in C# regex?

Sunday, August 22nd, 2010

How do I use the inline modifiers instead of RegexOptions.Option?

For example:

Regex MyRegex = new Regex(@"[a-z]+", RegexOptions.IgnoreCase);

How do I rewrite this using the inline character i?

http://msdn.microsoft.com/en-us/library/yd1hzczs.aspx

using Microsoft.Web.UI.WebControl in .NET 2.0

Sunday, August 22nd, 2010

Is it possible to use Microsoft.Web.UI.WebControl in .NET 2.0?

On the page

http://msdn.microsoft.com/en-us/library/ms529254%28v=VS.85%29.aspx

you cant even download them!

On the page

http://www.asp.net/downloads/archived-v11/ie-web-controls

it is said that "The Internet Explorer Web Controls is an archived ASP.NET 1.1 download".

Sync Framework 2.0 Error: The specified change tracking operation is not supported.

Sunday, August 22nd, 2010

I’m fairly new to the MS Sync framework and have been beating my head against the wall for about four hours now to no avail. I’m simply trying to sync my databases (one “master” SQL Server 2008 with a SQL Server CE, the client) with:

Dim syncAgent As DataCacheSyncAgent = New DataCacheSyncAgent()
Dim syncStats As Microsoft.Synchronization.Data.SyncStatistics = syncAgent.Synchronize()

It works just fine in Visual Studio 2010 and always manages to sync, but now that I’m trying to implement it on my client’s computers, I always get the error:

The specified change tracking operation is not supported. To carry out this operation on the table, disable the change tracking on the table, and enable the change tracking.

I’ve tried everything that I can think of to no avail, but like I said I’m new to the sync framework and haven’t found much help on Google. I’ve tried turning change tracking off and back on (on the server via SQL Mgmt Studio), but that didn’t work either. Perhaps it meant I should turn it off & back on in the client? How might I accomplish that programmaticly?

Does operator ++ (int x) create new instance every time?

Sunday, August 22nd, 2010

According to MSDN, System.Int32 is immutable, and its members always return new instances.
Some common code, like for loop, requires ++ operation quite often.
Does increment always create new instances and discard the old ones? As far as I can see, this approach will severely affect the performance. And I wonder how Microsoft implements it.

By the way, is increment thread-safe? In documentation, it says all the members of Int32 are thread-safe, but there is interlocked.increment().

Thanks.

SQLite 64-bit library crashes when sqlite3_prepare_v2 fails

Saturday, August 21st, 2010

I’m compiling both a 32-bit and 64-bit SQLite library with Microsoft Visual C++ from the command line for a simple C# wrapper. The 32-bit version works fine, but the 64-bit version crashes my application completely when sqlite3_prepare_v2 returns anything but SQLITE_OK.

build.bat

set ARGS=/nologo /LD /DSQLITE_ENABLE_COLUMN_METADATA sqlite3.c /link /def:sqlite3.def

call vcvars32.bat
cl %ARGS% /out:sqlite3.dll

call vcvars64.bat
cl %ARGS% /out:sqlite3_64.dll

C# code (relevant bits)

public delegate int _sqlite3_prepare_v2(IntPtr db, string zSql, int nByte, out IntPtr ppStmt, out IntPtr pzTail);

public static readonly _sqlite3_prepare_v2 sqlite3_prepare_v2;

IntPtr tail;
if (SQLite.sqlite3_prepare_v2(_db.Handle, text, -1, out _handle, out tail) != SQLite.SQLITE_OK)
    throw new SQLiteException(_db);

The functions are bound at runtime so that I can compile for Any CPU and choose which version of the library to use. When I run this on a 64-bit system, I get this:

vshost-clr2.exe has stopped working
Problem signature:
  Problem Event Name:       APPCRASH
  Application Name:         SQLiteTest.vshost.exe
  Application Version:      10.0.30319.1
  Application Timestamp:    4ba2084b
  Fault Module Name:        StackHash_4a05
  Fault Module Version:     6.1.7600.16559
  Fault Module Timestamp:   4ba9b802
  Exception Code:           c0000374
  Exception Offset:         00000000000c6df2
  OS Version:               6.1.7600.2.0.0.256.48
  Locale ID:                1033
  Additional Information 1: 4a05
  Additional Information 2: 4a055724055f1d4270656b7cd547877a
  Additional Information 3: 92b7
  Additional Information 4: 92b737f393457f0de2d4edb6b32c0617

Any ideas?

EDIT: The message I get when debugging the application is:

A heap has been corrupted