Public key token for a dll can be checked using a simple command in PowerShell.
Open Windows PowerShell window.
Run the command "[system.reflection.assembly]::loadFile("DllPath").FullName
Monday, April 24, 2017
Sunday, April 16, 2017
How to determine if a dll is built for 32-bit, 64bit or Any CPU
CorFlags.exe is part of the .NET Framework SDK. I have the development tools on my machine, and the simplest way for me determine whether a DLL is 32-bit only is to:
- Open the Visual Studio Command Prompt (In Windows: menu Start/Programs/Microsoft Visual Studio/Visual Studio Tools/Visual Studio 2008 Command Prompt)
- CD to the directory containing the DLL in question
- Run corflags like this: corflags MyAssembly.dll
You will get output something like this:
Microsoft (R) .NET Framework CorFlags Conversion Tool. Version 3.5.21022.8
Copyright (c) Microsoft Corporation. All rights reserved.
Version : v2.0.50727
CLR Header: 2.5
PE : PE32CorFlags : 3
ILONLY : 1
32BIT : 1
Signed : 0
The key is the "32BIT" flag as documented above: 1 = x86; 0 = Any CPU.
For x64 only the output would be (plus after 32): PE: PE32+
How to read connection string
string connectionString = ConfigurationManager.ConnectionStrings[connectionName].ConnectionString;
Make sure to add reference to System.configuration in your project.
Wednesday, April 12, 2017
How to open a file locked by other process
Trying to open a file which is being used by another process will result in an exception.
For example, when we try to open a word document opened and locked by other process, we will get an exception.
Here is the sample code that results in exception:
Here is the sample code that results in exception:
using (FileStream fs = new FileStream(fileToUpload, FileMode.Open, FileAccess.Read))
{
fileContents = new Byte[fs.Length];
fs.Read(fileContents, 0, Convert.ToInt32(fs.Length));
}
Inorder to resolve this,
we need to use another overload of the FileStream constructor.
Just add FileShare.ReadWrite to the parameters.
using (FileStream fs = new FileStream(fileToUpload, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
{
fileContents = new Byte[fs.Length];
fs.Read(fileContents, 0, Convert.ToInt32(fs.Length));
}
This overload of the FileStream constructor allows to open a file in a non-exclusive mode.
Thursday, April 6, 2017
Error: A table, Extended Data Type, Base Enum or class called {TableName} already exists. Import of table aborted.
Sometimes during import of an xpo file, we might encounter the following error:
A table, Extended Data Type, Base Enum or class called {TableName} already exists. Import of table aborted.
This errors is a critical error and it stops the import of xpo.
REASON: In majority of cases this error is due to caching.
FIX: In order to resolve this, clear all cache files - .AUC files from the users AppData folder.
A table, Extended Data Type, Base Enum or class called {TableName} already exists. Import of table aborted.
This errors is a critical error and it stops the import of xpo.
REASON: In majority of cases this error is due to caching.
FIX: In order to resolve this, clear all cache files - .AUC files from the users AppData folder.
- Close AX 2012 client
- Browse to the folder "C:\Users\{userName}\AppData\Local (Windows 2012 Server)
- Delete all AUC files
- Start AX 2012 client and start import.
#Happy coding :)
Subscribe to:
Posts (Atom)