Explorer OM is not supported in a 64bit process - c#

I was trying to create send ports using C# .NET through following code :
using Microsoft.BizTalk.ExplorerOM;
private void CreateSendPort()
{
// connect to the local BizTalk Management database
BtsCatalogExplorer catalog = new BtsCatalogExplorer();
catalog.ConnectionString = "Server=.;Initial Catalog=BizTalkMgmtDb;Integrated Security=SSPI;";
try
{
// create a new static one-way SendPort
SendPort myStaticOnewaySendPort = catalog.AddNewSendPort(false, false);
myStaticOnewaySendPort.Name = "myStaticOnewaySendPort1";
myStaticOnewaySendPort.PrimaryTransport.TransportType = catalog.ProtocolTypes[0];
myStaticOnewaySendPort.PrimaryTransport.Address = "http://sample1";
myStaticOnewaySendPort.SendPipeline = catalog.Pipelines["Microsoft.BizTalk.DefaultPipelines.XMLTransmit"];
// create a new dynamic two-way sendPort
SendPort myDynamicTwowaySendPort = catalog.AddNewSendPort(true, true);
myDynamicTwowaySendPort.Name = "myDynamicTwowaySendPort1";
myDynamicTwowaySendPort.SendPipeline = catalog.Pipelines["Microsoft.BizTalk.DefaultPipelines.XMLTransmit"];
myDynamicTwowaySendPort.ReceivePipeline = catalog.Pipelines["Microsoft.BizTalk.DefaultPipelines.XMLReceive"];
// persist changes to BizTalk Management database
catalog.SaveChanges();
}
catch(Exception e)
{
catalog.DiscardChanges();
throw e;
}
}
Source
But I'm getting following issue
Explorer OM is not supported in a 64bit process.
when this line is executed :
BtsCatalogExplorer catalog = new BtsCatalogExplorer();
I'm well aware of the fact i.e. : "Warning
Microsoft.BizTalk.ExplorerOM.dll is only supported if used from 32 bit processes. If you are building a solution for a 64 bit system you should not use this library."
But in this case how can I create send ports on 64bit machine, Can anybody please help me with this?

Force it to run in a 32 bit process.
http://lostechies.com/gabrielschenker/2009/10/21/force-net-application-to-run-in-32bit-process-on-64bit-os/

As of BizTalk 2010, this restriction was lifted and ExplorerOM can be used in 64-bit and 32-bit processes.

Related

Get Linux server time from windows service c#

Is there anyway I can get linux server time from windows service given linux server IP ? I tried to use Cliwrap (https://github.com/Tyrrrz/CliWrap) and wrote the following function but it is not working as well:
public string GetLinuxServerTime()
{
using (var cli = new Cli("bash.exe"))
{
// Execute
var output = cli.Execute("ssh user#10.104.12.114 date");
return "abc";
}
}
Kindly suggest some another way.

In what versions of Windows are Storage Management API Classes such as 'MSFT_PhysicalDisk' implemented?

I am trying pull metrics such as 'MediaType' from MSFT_PhysicalDisk. I'm successful on a Windows 10 machine, but not on a Windows 7 machine.
On what type of machines is MSFT_PhysicalDisk available?
The reference for Storage Management API Classes:
https://learn.microsoft.com/en-us/previous-versions/windows/desktop/stormgmt/storage-management-api-classes
See code below for an example of what I'm trying to do:
bool isSsd;
try
{
var physDiskQuery =
$"SELECT MediaType FROM MSFT_PhysicalDisk WHERE DeviceID='{driveNumber.Value}'";
var wmiScope = #"\\.\root\microsoft\windows\storage";
using (var physicalDiskSearcher = new ManagementObjectSearcher(wmiScope, physDiskQuery))
{
var objectCollection = physicalDiskSearcher.Get();
var physicalDisk = objectCollection.Cast<ManagementBaseObject>().SingleOrDefault();
if (physicalDisk == null)
return null;
isSsd = (ushort)physicalDisk["MediaType"] == 4;
}
}
catch (Exception exception)
{
Debug.WriteLine($"Error while checking for SSD drive. Details: {exception.GetBaseException()}");
return null;
}
return isSsd;
MSDN documentation lists requirements way at the bottom of the page. For the MSFT_PhysicalDisk class it says...
Minimum supported client: Windows 8 [desktop apps only]
Minimum supported server: Windows Server 2012 [desktop apps only]
In other words, you need at least Windows version 6.2.

Having trouble retrieving collection from MongoDB database

I am trying to learn MongoDB for my next project. I have installed MongoDB on my Windows 7 machine. I am able to create collection and retrieve data using mongo.exe. I am trying to use official C# driver to manipulate collection but my test console application goes in "abyss" while trying to connect to server (I guess).
I have written following code:
static void Main(string[] args)
{
try
{
// Create server settings to pass connection string, timeout, etc.
var settings = new MongoServerSettings();
settings.Server = new MongoServerAddress("localhost", 27017);
// Create server object to communicate with our server
var server = new MongoServer(settings);
server.Connect(TimeSpan.FromMilliseconds(1000));
// Get our database instance to reach collections and data
var message = string.Empty;
server.IsDatabaseNameValid("test", out message);
Console.WriteLine(message);
var database = server.GetDatabase("test");
var users = database.GetCollection("users").FindAll();
foreach (var user in users)
{
Console.WriteLine("User found");
}
}
catch (Exception ex)
{
Console.WriteLine(ex.InnerException);
Console.WriteLine(ex.StackTrace);
}
Console.ReadLine();
}
Console application stops working on line server.Connect(). I have put this line just to find problem, I know it is not necessary to connect to server explicitly. If I remove that line then Console application stops working on line foreach (var user in users)
I also tried to get server using following code with no success:
var mongoClient = new MongoClient("mongodb://<host>:27017");
var server = mongoClient.GetServer();
Code is perfect! It was idiosyncrasy of MongoDB that when you try to connect to MongoDB through C# driver, you will have to accept connection for first time. Next time onwards MongoDB will remember your last acceptance and move on.
There has to be setting to remove this condition but I haven't found it yet. I will update as soon as possible.
Happy MangoDB Learning.
use your last example like this:
var mongoClient = new MongoClient("mongodb://localhost");
var server = mongoClient.GetServer();
Unless it's not running on the same machine or not on the standard port

Windows 8 app how to connect to Socket server

i have done a server using this example socketAsyncEventArgs
in visual studio 2010 and .net 4.0.
Now i'm trying to connect to it from a windows 8 app using StreamSocket but i'm getting a "Acces denied" message.
here is the Client code:
private StreamSocket streamSocket;
public string Server = "192.168.0.101";
public int Port = 9900;
public async void Connect()
{
streamSocket = new StreamSocket();
Connect();
try
{
await streamSocket.ConnectAsync(
new Windows.Networking.HostName(Server),
Port.ToString()); // getting Acces Denied here
DataReader reader = new DataReader(streamSocket.InputStream);
reader.InputStreamOptions = InputStreamOptions.Partial;
while (true)
{
var bytesAvailable = await reader.LoadAsync(1000);
var byteArray = new byte[bytesAvailable];
reader.ReadBytes(byteArray);
}
}
catch (Exception e)
{
MessageBox(e.StackTrace);
}
}
How to fix the problem? Is there another way to send and receive messages using this server?
You are probably also seeing the following as part of your error message:
WinRT information: A network capability is required to access this network resource
This is because you need to add a capability to your application that allows you to access local networks. Double click on the Package.appxmanifest file in your project. Click on the Capabilities tab. Add the Private Networks (Client & Server) capability to your project.

check whether microsoft components are present or not

I want to check whether certain microsoft components like wmencoder, directx or wmplayer
are installed or not. If it is installed, can I also get its version number?
How can I do that?
Thanks in advance.
I use the below to determine if other applications are installed, however you will need to know the "unique" product code (from the setup project in Visual Studio) that the application is installed with in the registry.
Include
using System.Diagnostics;
using Microsoft.Win32;
Usage:
// HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID\{0006F03A-0000-0000-C000-000000000046} << This is outlook 2003
String retval = "";
// Look to see if Outlook 2003 is installed and if it is...
if ((checkComServerExists("{0006F03A-0000-0000-C000-000000000046}", out retval)))
{
// Update boolean flag if we get this far so we don't have to check again
Console.WriteLine("Office CSLID exists - Version: " + retval);
}
Function:
// Checks to see if the given CLSID is registerd and exists on the system
private static Boolean checkComServerExists(String CLSID, out String retval)
{
RegistryKey myRegKey = Registry.LocalMachine;
Object val;
try
{
// get the pathname to the COM server DLL/EXE if the key exists
myRegKey = myRegKey.OpenSubKey("SOFTWARE\\Classes\\CLSID\\" + CLSID + "\\LocalServer32");
val = myRegKey.GetValue(null); // the null gets default
}
catch
{
retval = "CLSID not registered";
return false;
}
FileVersionInfo myFileVersionInfo = null;
try
{
// parse out the version number embedded in the resource
// in the DLL
myFileVersionInfo = FileVersionInfo.GetVersionInfo(val.ToString());
}
catch
{
retval = String.Format("DLL {0} not found", val.ToString());
return false;
}
retval = myFileVersionInfo.FileVersion;
return true;
}
My first thought would be WMI. Class Win32_SoftwareElement (on MSDN)
But likely to take some work to get the right classes and queries. Start with the WMI tools for WMI CIM Studio.
Using PowerShell, something like:
gwmi win32_softwareelement -filter "name like '%play%'" | ft
will allow finding the right ids. (Warning: this is extremely slow.)
Possible that the MS Installer (MSI) API has something quicker.
I use RegShot to determine registry setting that can be used to check if a softwre is installed ..
Here is also a small code snippet that uses, among others, Type.GetTypeFromProgID and registry access.

Categories