Getting Error Retrieving the COM class factory for component with CLSID{} - c#-3.0

when i want to add the new customer on quick book through c#.i am getting this error:
Retrieving the COM class factory for component with CLSID {178AACCA-9DCE-42A0-A193-CF4985B930E5} failed due to the following error: 80040154.
here is a code where i found error..
Please write valid answer... thanks..
try
{
//Create the session Manager object
sessionManager = new QBSessionManager();
//Create the message set request object to hold our request
IMsgSetRequest requestMsgSet = sessionManager.CreateMsgSetRequest("US", 8, 0);
requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue;
//Connect to QuickBooks and begin a session
sessionManager.OpenConnection("App1", "QuickBooks");
connectionOpen = true;
sessionManager.BeginSession(#"C:\Users\Public\Documents\Intuit\QuickBooks\Company Files\PSNew.QBW", ENOpenMode.omDontCare);
sessionBegun = true;
ICustomerAdd customerAddRq = requestMsgSet.AppendCustomerAddRq();
customerAddRq.Name.SetValue(CP.CustomerName);
customerAddRq.LastName.SetValue(CP.CustomerLastName);
customerAddRq.Email.SetValue(CP.CustomerEmail);
//Send the request and get the response from QuickBooks
IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet);
IResponse response = responseMsgSet.ResponseList.GetAt(0);
ICustomerRet customerRet = (ICustomerRet)response.Detail;
CP.GetCustomerId = customerRet.ListID.GetValue();
CP.GetCustomerName = customerRet.Name.GetValue();
CP.GetCustomerEmail = customerRet.Email.GetValue();
//CP.customerAddRq1 = customerAddRq.Name.GetValue();
}
catch (Exception)
{
throw;
}
finally
{
//End the session and close the connection to QuickBooks
if (sessionBegun)
{
sessionManager.EndSession();
}
if (connectionOpen)
{
sessionManager.CloseConnection();
}

make sure that your app is compiled with the project build configurations set to x86 for the target platform. This is the most common solution on the net given that Intuit integration dlls are 32-bit. However in my case when I faced this problem, I decided to install the QuickBooks SDK to the client machine and that's when I succeeded in solving it.

Related

Get product list from Huawei In app purchase

So, i want to get my products list from my Huawei developer account, i integrate the sdk and all it's fine. the issue here in this code :
Future<List<ProductInfo>> getConsumableProducts() async {
try {
ProductInfoReq req = ProductInfoReq(); // The named parameter 'skuIds' is required, but there's no corresponding argument.Try adding the required argument.dartmissing_required_argumentThe named parameter 'priceType' is required, but there's no corresponding argument.Try adding the required argument.dartmissing_required_argument
req.priceType = IapClient.IN_APP_CONSUMABLE;
req.skuIds = ["prod_01", "prod_02"];
ProductInfoResult res = await IapClient.obtainProductInfo(req);
return res.productInfoList; // A value of type 'List<ProductInfo>?' can't be returned from the method 'getConsumableProducts' because it has a return type of 'Future<List<ProductInfo>>'
} on PlatformException catch (e) {
log(e.toString());
return null;
}
}
i mention the issues in the code. P.S : i made a search and verify that this code is the same code which public
If you want to obtain purchase information, you could follow the code below:
List<String> productIdList = new ArrayList<>();
// Only those products already configured in AppGallery Connect can be queried.
productIdList.add("ConsumeProduct1001");
ProductInfoReq req = new ProductInfoReq();
// priceType: 0: consumable; 1: non-consumable; 2: subscription
req.setPriceType(0);
req.setProductIds(productIdList);
// Obtain the Activity object that calls the API.
final Activity activity = getActivity();
// Call the obtainProductInfo API to obtain the details of the product configured in AppGallery Connect.
Task<ProductInfoResult> task = Iap.getIapClient(activity).obtainProductInfo(req);
Check here for more info.

Plug-In that Converted Note entity pre-existing attachment XML file into new .MMP file

strong text [Plugin error at Note entity][1]
[1]: http://i.stack.imgur.com/hRIi9.png
Hi,Anyone resolved my issue i got a Plug-in error which i worked at Update of "Note" entity.Basically i want a Plugin which converted pre-exiting Note attachment XML file into new .MMP extension file with the same name.
I have done following procedure firstly i created a "Converter_Code.cs" dll which contains Convert() method that converted XML file to .MMP file here is the constructor of the class.
public Converter(string xml, string defaultMapFileName, bool isForWeb)
{
Xml = xml;
DefaultMapFileName = defaultMapFileName;
Result = Environment.NewLine;
IsForWeb = isForWeb;
IsMapConverted = false;
ResultFolder = CreateResultFolder(MmcGlobal.ResultFolder);
}
In ConvertPlugin.cs Plug-in class firstly i retrieved Note entity attachment XML file in a string using following method in
IPluginExecutionContext context =(IPluginExecutionContext)serviceProvider.
GetService (typeof(IPluginExecutionContext));
IOrganizationServiceFactory serviceFactory= (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
IOrganizationService service = serviceFactory.CreateOrganizationService
(context.UserId);
if (context.InputParameters.Contains("Target")
&& context.InputParameters["Target"] is Entity)
{
// Obtain the target entity from the input parameters.
Entity entity = (Entity)context.InputParameters["Target"];
var annotationid = entity.GetAttributeValue<Guid>("annotationid");
if (entity.LogicalName != "annotation")
{
return;
}
else
{
try
{
//retrieve annotation file
QueryExpression Notes = new QueryExpression { EntityName ="annotation"
,ColumnSet = new ColumnSet("filename", "subject", "annotationid",
"documentbody") };
Notes.Criteria.AddCondition("annotationid", ConditionOperator.Equal,
annotationid);
EntityCollection NotesRetrieve = service.RetrieveMultiple(Notes);
if (NotesRetrieve != null && NotesRetrieve.Entities.Count > 0)
{
{
//converting document body content to bytes
byte[] fill = Convert.FromBase64String(NotesRetrieve.Entities[0]
.Attributes["documentbody"].ToString());
//Converting to String
string content = System.Text.Encoding.UTF8.GetString(fill);
Converter objConverter = new Converter(content, "TestMap", true);
objConverter.Convert();
}
}
}
catch (FaultException<OrganizationServiceFault> ex)
{
throw new InvalidPluginExecutionException("something is going wrong");
}
}
}
}
and than A string is passed to "Converter" constructor as a parameter.
finally i merged all dll using ILMerge following method:
ilmerge /out:NewConvertPlugin.dll ConvertPlugin.dll Converter_Code.dll
and NewConvertPlugin is registered successfully but while its working its generate following error:
Unexpected exception from plug-in (Execute): ConverterPlugin.Class1: System.Security.SecurityException: That assembly does not allow partially trusted callers.
i also debug the plugin using Error-log but its not worked so i could not get a reason whats going wrong.
The error is caused by the library you merged inside your plugin.
First of all you are using CRM Online (from your screenshot) and with CRM Online you can use only register plugins inside sandbox.
Sandbox means that your plugins are limited and they run in a partial-trust environment.
You merged an external library that requires full-trust permissions, so your plugin can't work and this is the reason of your error.
Because you are in CRM Online, or you find another library (the Converter) that requires only partial-trust, hoping that the merge process will work, or you include (if you have it) the source code of the converter library directly inside your plugin.

NullReferenceException occurs during offline sync to Azure Mobile Service

I am trying to make offline sync to table from azure mobile service. My Xamarin Form version is 1.4.2.6359.
I try to test my code in OnCreate method of MainActivity. All preparation steps such as MobileServiceClient initialization, MobileServiceSQLiteStore initialization, SyncTable creation, etc are ok.
When I try to call PullAsync, I am getting NullReferenceException. I capture the package using Package Capture App from mobile. The request goes to Azure Mobile service and it returns the correct json data successfully.
When I try the same code in Xamarin Android project (not Xamarin Form), it is working fine.
To reproduce the issue.
Just create Xamarin Form (Portable) project and use my code.
My Code
private async Task Test() {
const string applicationURL = #"https://xxxx.azure-mobile.net/";
const string applicationKey = #"xxxx";
CurrentPlatform.Init();
var client = new MobileServiceClient(applicationURL, applicationKey);
string path = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "store.db");
if (!File.Exists(path)) {
File.Create(path).Dispose();
}
var store = new MobileServiceSQLiteStore(path);
store.DefineTable<Product>();
await client.SyncContext.InitializeAsync(store);
var productTable = client.GetSyncTable<Product>();
try {
await client.SyncContext.PushAsync();
await productTable.PullAsync("allProducts", productTable.CreateQuery());
var t = await productTable.ToListAsync();
Console.WriteLine("Product Count : " + t.Count);
}
catch (Java.Net.MalformedURLException ex) {
Console.WriteLine(ex.Message);
}
catch (Exception e) {
Console.WriteLine(e.Message);
}
}
References:
http://azure.microsoft.com/en-us/documentation/articles/mobile-services-xamarin-android-get-started-offline-data/
http://blogs.msdn.com/b/carlosfigueira/archive/2014/04/07/deep-dive-on-the-offline-support-in-the-azure-mobile-service-managed-client-sdk.aspx
I got the solution for this case.
As far as my understanding, this is what is happening. During the application is loading, I call PullAsync. It is async call and during this call, application keeps loading other components. The actual NullReferenceException is coming from OnPrepareOptionsMenu function (Xamarin.Forms.Platform.Android.AndroidActivity.OnPrepareOptionsMenu). The exception is happening on other thread and the thread simply dies. That's why I cannot get stack trace from my main thread.
This NullReferenceException issue is totally not related to Azure Mobile Service.
I override OnPrepareOptionsMenu in MainActivity and add try-catch block to base class function call. The problem is solved. Here is my code in MainActivity class.
public override bool OnPrepareOptionsMenu(IMenu menu) {
try {
// I am always getting menu.HasVisibleItems = false in my app
if (menu != null && menu.HasVisibleItems) {
// Exception is happening when the following code is executed
var result = base.OnPrepareOptionsMenu(menu);
return result;
}
}
catch{
}
return true;
}
I don't really understand why it is happening. Please point me out if you have better understanding of this case and better solution.
I think my issue is same as this : http://forums.xamarin.com/discussion/23579/exception-whilte-trying-to-open-activity-from-xamarin-forms-page

java api to get a file content for enterprise github

I tried so hard for a simple line of code that read a file content from enterprise github with oauth token, but could not find a example of such.
I tried https://github.com/jcabi/jcabi-github, but it does not support enterprise github?(maybe I am wrong)
Now i am trying egit:
GitHubClient client = new GitHubClient("enterprise url");
GitHubRequest request = new GitHubRequest();
request.setUri("/readme");
GitHubResponse response = client.get(request);
Then what? I only saw a getBody, maybe I need to parse it with some kinda json library? It has to be simpler..I am expecting something like: repo.get(url).getContent()
Finally figure out by reading source code..
GitHubClient client = new GitHubClient(YOURENTERPRICEURL);
client.setOAuth2Token(token);
// first use token service
RepositoryService repoService = new RepositoryService(client);
try {
Repository repo = repoService.getRepository(USER, REPONAME);
// now contents service
ContentsService contentService = new ContentsService(client);
List<RepositoryContents> test = contentService.getContents(repo, YOURFILENAME);
List<RepositoryContents> contentList = contentService.getContents(repo);
for(RepositoryContents content : test){
String fileConent = content.getContent();
String valueDecoded= new String(Base64.decodeBase64(fileConent.getBytes() ));
System.out.println(valueDecoded);
}
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}

CRM 2011 - Plug-In - Operation Timed-Out error while trying to do a HTTP Post in a Plug-in

I'm having problems when I try to do a HTTP Post in my Plugin (in PostUpdate). I'm getting the "The Operation Has Timed Out"-Error...
Here below you have the C#-code :
//PUBLISH TO ROBAROV
WebRequest webRequest = WebRequest.Create(newUri);
webRequest.Timeout = 2000;
webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.Method = "POST";
byte[] bytes = Encoding.ASCII.GetBytes(parameters);
Stream os = null;
try
{
webRequest.ContentLength = bytes.Length;
os = webRequest.GetRequestStream();
os.Write(bytes, 0, bytes.Length);
}
catch (WebException ex)
{
throw new Exception(ex.Message);
}
finally
{
if (os != null)
{
os.Close();
}
}
//ERROR HAPPENS HERE
string responseText = "";
try
{ // get the response
WebResponse webResponse = webRequest.GetResponse();
StreamReader sr = new StreamReader(webResponse.GetResponseStream());
responseText = sr.ReadToEnd().Trim();
}
catch (WebException ex)
{
throw new Exception("Error with response : " + ex.Message);
}
The error happens when I'm trying to get the response => webRequest.GetResponse();!
I've tried the code out in a simple "Class"-library and there it works like a charm! Is there something I'm doing wrong? The HTTP Post is to a webpage that's not in the same domain....
UPDATE :
Same happens when I do the following with a webclient... And it works in a normal "Console"-application :
private string HttpPostTest(string URL)
{
WebClient webClient = new WebClient();
System.Collections.Specialized.NameValueCollection formData = new System.Collections.Specialized.NameValueCollection();
formData["state"] = "yes";
byte[] responseBytes = webClient.UploadValues(URL, "POST", formData);
string Result = Encoding.UTF8.GetString(responseBytes);
return Result;
}
I'm getting the following error in the "Event Viewer" :
Inner Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.Crm.Setup.DiffBuilder, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
It looks like it can't find a CRM assembly: Microsoft.Crm.Setup.DiffBuilder.dll, is this something which you explicitly call methods from? If so I'd check if the assembly is registered with the plug-in (some instructions below). If not then there are some errors associated with this library from roll up 6, which roll up are you using? You may consider roll up 7 if you are not using that.
Is your plug-in registered in the database or on disk?
If registered on disk then you will need your external assembly in the /server/bin/assembly directory under the CRM installation folder.
If it is registered in the database and you are including a custom external assembly (the error suggests that an assembly cannot be loaded, so this sounds possible), then you will have to ILMerge your assemblies before registering them in the database. This would explain why it works for your local console application and not when run as a plug-in.
If this is the case then you can follow a script like below to ILMerge and register your 'combined' assembly:-
http://www.2wconsulting.com/2010/11/using-ilmerge-with-crm-plugin-assemblies/