COMAdminCatalogCollection.Populate throws error C# - c#

I am using the COMAdminCatalog API for .net. I am currently getting certain properties of COM+ applications and components from an array of servers remotely. For the most part, my process doesn't have a problem retrieving this data. However, a few of the COM+ application's components will not populate and throws the following exception:
Error Message: Errors occurred accessing one or more objects - the ErrorInfo collection may have more detail (Exception from HRESULT: 0x80110401)
I try getting the ErrorInfo collection, but no errorInfo objects are returned, so that doesn't help me in trouble shooting.
Here is the documentation:
https://msdn.microsoft.com/en-us/library/windows/desktop/ms686530(v=vs.85).aspx
Here is the method I am using to try to populate a component collection. Any help would be greatly appreciated. Thanks in advance
private static bool TryPopulateComponent(COMAdminCatalogCollection cOMAdminCatalogComponentCollection,
COMAdminCatalogObject application = null, COMAdminCatalogObject component = null, string serverName = null)
{
try
{
cOMAdminCatalogComponentCollection.Populate();
return true;
}
catch (Exception ex)
{
COMAdminCatalogCollection errorInfos = cOMAdminCatalogComponentCollection.GetCollection("ErrorInfo", varObjectKey: application.Key);
errorInfos.Populate();
foreach (COMAdminCatalogObject errorInfo in errorInfos)
{
var errorCode = errorInfo.Value["ErrorCode"];
var majorRef = errorInfo.Value["MajorRef"];
var minorRef = errorInfo.Value["MinorRef"];
var name = errorInfo.Value["Name"];
}
COMException comException = new COMException(ex.Message, ex.InnerException,
application, component, serverName);
Console.WriteLine($"Could not populate {component?.Name}");
Console.WriteLine(ex.Message);
LogTools.LogError(comException);
return false;
}
}

Related

Automatically generate nodes in a Canoe configuration simulation

I am trying to automate and create a Canoe simulation.
My usecase :
I have a configuration (LibraryTest.cfg) with a CAN Network and a node ACAN in the network. I want to create another node BCAN automatically into the existing configuration along with ACAN. I am trying this using C# .NET Canoe Library for this.
CANoe.Application mApp;
CANoe.Measurement mMsr;
CANoe.Networks mNet;
mApp = new CANoe.Application();
string ConfigFile=
"C:\\Users\\deepasreeraj\\Desktop\\GAC\\TestUnit1\\LibraryTest.cfg";
try
{
mApp.Open(ConfigFile, true, true);
mMsr = (CANoe.Measurement)mApp.Measurement;
mNet = mApp.Networks;
CANoe.Simulation mSim = mApp.Simulation;
if (mNet != null)
{
if(mNet != null)
{
int count = mNet.Count;
for (int i = 0; i < count; i++)
{
mNet.Add("BCAN");
string Nodename = mNet[i].NetworkInterfaces;
}
}
}
}
catch (System.Exception ex)
{
System.Console.WriteLine(ex.Message);
}
}
In this, while the code reaches mNet.Add("BCAN"); it gives an exception "The method or operation is not implemented." Can someone please help me with this?
If you want to add a node, the Networks property is wrong.
You have to use mApp.Configuration.SimulationSetup.Buses.Nodes. There you can call Add to add a new node.
Just check the page Technical References -> COM Interface -> Object Hierarchy in the CANoe help for the complete API Reference.

Integrating IM applications with outlook 2010/2013

I have implemented the IM application (name is "ContactCardDesktop.exe") as suggested by the link https://msdn.microsoft.com/en-us/library/office/jj900715(v=office.15).aspx
I have done all the registry setting per the article. but there is no call to outlook to IM application for function GetAuthenticationInfo() and GetInterface().
Even not getting the ProcessID at registry location HKCU\Software\IM Providers\ContactCardDesktop.
In outlook logs I am getting errors attached below. I have gone through to many suggestion but didn't get help much.
Please suggest the problem/solution.
Sample code for Application.
[ClassInterface(ClassInterfaceType.None)]
[ComSourceInterfaces(typeof(_IUCOfficeIntegrationEvents))]
[ProgId("LitwareClientAppObject.Class")]
[Guid("449B04AD-32A8-4D21-B0AE-8FC316E051CE"), ComVisible(true)]
public partial class LitwareClientAppObject : IUCOfficeIntegration
{
IMClient imClient;
Automation imAutomation;
public LitwareClientAppObject()
{
InitializeComponent();
imClient = new IMClient();
imAutomation = new IMClientAutomation();
}
// Implementation details omitted.
public string GetAuthenticationInfo(string _version)
{
string supportedOfficeVersion = "15.0.0.0";
// Do a simple check for equivalency.
if (supportedOfficeVersion == _version)
{
return "<authenticationinfo>";
}
else
{
return null;
}
}
public object GetInterface(string _version, OIInterface _interface)
{
IMClient imClient = new IMClient();
IMClientAutomation imAutomation = new IMClientAutomation();
switch (_interface)
{
case OIInterface.oiInterfaceILyncClient:
{
return imClient;
}
case OIInterface.oiInterfaceIAutomation:
{
return imAutomation;
}
default:
{
throw new NotImplementedException();
}
}
}
public OIFeature GetSupportedFeatures(string _version)
{
OIFeature supportedFeature1 = OIFeature.oiFeatureQuickContacts;
OIFeature supportedFeature2 = OIFeature.oiFeatureFastSearch;
return (supportedFeature1 | supportedFeature2);
}
Errors like:
CMsoIMProviderFactory::HrEnsureDefaultIMAppRegKeys Succeeded opening reg key (HKCU:SOFTWARE\IM Providers)
CMsoIMProviderFactory::HrEnsureDefaultIMAppRegKeys Succeeded querying reg key (HKCU:SOFTWARE\IM Providers:DefaultIMApp:ContactCardDesktop)
CMsoIMProviderFactory::HrEnsureDefaultIMProcessRegKey Succeeded opening reg key (HKCU:SOFTWARE\IM Providers\ContactCardDesktop)
CMsoIMProviderFactory::HrEnsureDefaultIMProcessRegKey Succeeded opening reg key (HKLM:SOFTWARE\IM Providers\ContactCardDesktop)
CMsoIMProviderFactory::WhichMessengerInProcessList Using (ContactCardDesktop.exe) process name for search
CMsoIMProviderFactory::WhichMessengerInProcessList Using (ContactCardDesktop.exe) process name for search hr = 80040154, We couldn't identify the provider type we now try to manually CoCreate using the LCClient CLSID
CMsoIMProviderFactory::HrGetAvailableProvider !failed! Line: 409 hr = 0x80040154 hr = 80040154, We couldn't identify the provider type we now try to manually CoCreate using the LCClient CLSID
CMsoIMProviderFactory::HrGetAvailableProvider !failed! Line: 289 hr = 0x80004005 !!!Provider Initialization Failed!!!
I have solved this issue to use COM server "CSExeCOMServer" that is at https://code.msdn.microsoft.com/windowsapps/CSExeCOMServer-3b1c1054

Error when adding Analysis Services Data Source View from c# code

I want to create an Analysis Services database, datasource and datasource view from c# code. Everything seems to be working fine until I add a mining structure and models and try to process the structure, then i get the following error:
Errors in the high-level relational engine. The data source view does
not contain a definition for the 'dbo_Challenger201501TrainingAll'
table or view. The Source property may not have been set.
The DSV is meant to contain the same info as a table in the Data Source.
This is the code with which i create the data set and DSV:
private static object FillDataSet(SqlConnection objConnection, DataSet objDataSet, string strTableName)
{
try
{
string strCommand = "Select * from " + strTableName;
SqlDataAdapter objEmpData = new SqlDataAdapter(strCommand, objConnection);
objEmpData.MissingSchemaAction = MissingSchemaAction.AddWithKey;
objEmpData.FillSchema(objDataSet, SchemaType.Source, strTableName);
Console.WriteLine(objEmpData.ToString());
return objDataSet;
}
catch (Exception ex)
{
Console.WriteLine("Error in Creating a DataSourceView - FillDataSet. Error Message -> " + ex.Message);
return null;
}
}
private static object CreateDataSourceView(Microsoft.AnalysisServices.Database objDatabase, RelationalDataSource objDataSource, DataSet objDataSet,
string strCubeDataSourceViewName)
{
try
{
Console.WriteLine("Creating DataSourceView ...");
DataSourceView objDataSourceView = new DataSourceView();
//Add Data Source View to the Database.
objDataSourceView = objDatabase.DataSourceViews.Add(strCubeDataSourceViewName);
objDataSourceView.DataSourceID = objDataSource.ID;
objDataSourceView.Schema = objDataSet;
objDataSourceView.Update();
return objDataSourceView;
}
catch (Exception ex)
{
Console.WriteLine("Error in Creating a DataSourceView - CreateDataSourceView. Error Message -> " + ex.Message);
return null;
}
}
The code compiles and runs fine. can anyone see any reason why the DSV may not be created properly?

MPEG-7 descriptors

I am trying to compare images by MPEG7 descriptors and I found a implementation by http://chatzichristofis.info/?page_id=19 but when I call Apply() function so the exception is thrown.
EHD_Descriptor ehd = new EHD_Descriptor(11);
var img = new Bitmap("LargerImage.jpg");
.
.
.
descriptor = ehd.Apply(img);
descriptor = ehd.Quant(descriptor);
Exception
System.AccessViolationException was unhandled
HResult=-2147467261
Message=...
Does anyone has any experiance with these descriptors or any reference to other descriptors which works without exceptions (from unmanaged code, I think)?
If someone has a same problem and just need to proccess other images, so one solution is:
[HandleProcessCorruptedStateExceptions]
[SecurityCritical]
private double[] DoSecurityCritical(SimpleRnd.CEDD cedd, Bitmap img) {
try {
// List<double[]> temp = locate.extract(img,600);
double [] temp = cedd.Apply(img);
return temp;
} catch (Exception) {
return null;
}
}
Just use stronger catch with security attributes.

Value does not fall within the expected range, IsolatedStorage

I have a class that I wrote that saves and retrieves any objects to a windows phone isolated storage system. Have a look...
public class DataCache
{
// Method to store an object to phone ************************************
public void StoreToPhone(string key, Object objectToStore)
{
var settings = IsolatedStorageSettings.ApplicationSettings;
try
{
if (existsInStorage(key))
{
settings.Remove(key);
settings.Add(key, objectToStore);
}
else
{
settings.Add(key, objectToStore);
}
}
catch (Exception e)
{
MessageBox.Show("An error occured while trying to cache data: " + e.Message);
}
}
// Method to retrieve an object ******************************************
public Object retrieveFromPhone(string key)
{
var settings = IsolatedStorageSettings.ApplicationSettings;
Object retrievedObject = null;
try
{
if (existsInStorage(key))
{
settings.TryGetValue<Object>(key, out retrievedObject);
}
else
{
MessageBox.Show(string.Format("Cannot find key {0} in isolated storage", key));
}
}
catch(Exception e)
{
MessageBox.Show("An error occured while trying to retrieve cache object: "+e.Message);
}
return retrievedObject;
}
// Helper method to check if there is space on the phone to cache the data
private bool IsSpaceAvailable(long spaceReq)
{
using (IsolatedStorageFile store = IsolatedStorageFile.GetUserStoreForApplication())
{
long spaceAvail = store.AvailableFreeSpace;
if (spaceReq > spaceAvail)
{
return false;
}
return true;
}
}
// Method to check if key exists in isolated storage *********************
public bool existsInStorage(string key)
{
var settings = IsolatedStorageSettings.ApplicationSettings;
bool objectExistsInStorage = settings.Contains(key);
return objectExistsInStorage;
}
}
When I run my app and try and store some data using my StoreToPhone() method I get the following error:
An error occurred while trying to cache data: Value does not fall within the expected range
I don't exactly know what this means.. Is it not expecting this type of object? I'm not sure... I'm passing it a custom class I wrote fyi.
Some times before I too ran into same problem.
It seems the error says 'there may be duplicate value in the storage'.
so i used 'remove' before 'add', and then also i found not everything was saved, so i used 'save' function after 'add'.
It worked for me...
IsolatedStorageSettings appSettings = IsolatedStorageSettings.ApplicationSettings;
appSettings.Remove("name");
appSettings.Add("name", "James Carter");
appSettings.Save();
tbResults.Text = (string)appSettings["name"];

Categories

Resources