I am currently trying to develop a custom ReadSoft Invoices plugin, nothing special.
I have gotten the plugin to work on two different machines, but the third machine I have, simply refuses to load the plugin.
The "funny" part about this, is that the third machine is a complete replica of the other two (they are all virtual machines).
The error shown when launching manager is: Plug-ins could not be loaded. (TESTPLUGIN(ClassName=TestPlugin.Test.Connect)).
I have run Regasm.exe on the dll so all the types are registered.
I have updated eilocal.ini with this:
;***********************
;* Manager *
;***********************
[Plugins::eimngr]
Plugin1=Common
Plugin2=DBMaintenance
Plugin3=ERPImport
Plugin4=InvoiceSelection
Plugin5=AutoValue
Plugin6=COLLECTOR
Plugin7=ReadSoft.InvoiceRules
Plugin8=TestPlugin
[eimngr::TestPlugin]
Name=TestPlugin
Type=COM
SupportIDispatch=TRUE
Classname=TestPlugin.Test.Connect
I have stripped all code from the plugin, just to make sure.
This is the code I am trying to run:
namespace TestPlugin
{
[ClassInterface(ClassInterfaceType.AutoDispatch)]
[ProgId("TestPlugin.Test.Connect")]
public class TestConnect
{
public TestConnect()
{
}
public int Connect(object objEHIApp, string sIniFile, string sIniSection)
{
File.AppendAllText(#"C:\ProgramData\ScanSolutions\TestPlugin.txt", "Plugin Connected!");
return 0;
}
public int Disconnect(object objEHIApp)
{
return 0;
}
public int IsVistaConverted()
{
return 0;
}
}
}
Since the error message from manager really does not help me track down the problem, I have been looking for a log, but have not yet found one.
To debug my issue I have then attached a debugger to the manager module, which just tells me this, when trying to load my plugin:
Could not create instance of class name TestPlugin.Test.Connect with
clsid {B21CE504-ADDA-3174-BEB8-D359F85D9A63}.
Does anyone what is happening here?
Thanks in advance.
Related
I have a c# library which provides some functionallity to upload data onto connected (android) devices. The dll itself gets exported via UnmangedExports to be used by an delphi application.
Here is the function which gets called by the delphi application:
[DllExport]
[return: MarshalAs(UnmanagedType.LPStr)]
public static string getDevices()
{
try
{
var devices = string.Empty;
var collection = new PortableDeviceCollection();
collection.Refresh();
foreach (var device in collection)
{
device.Connect();
if (devices != string.Empty)
{
devices += ";";
}
devices += device.FriendlyName;
device.Disconnect();
}
return devices;
}
catch (Exception e)
{
SomeClass.WriteErrorToLogFile(e);
return "ERROR";
}
}
Here is the class PortableDeviceCollection:
public class PortableDeviceCollection : Collection<PortableDevice>
{
private readonly PortableDeviceApiLib.PortableDeviceManagerClass _deviceManager;
public PortableDeviceCollection()
{
this._deviceManager = new PortableDeviceApiLib.PortableDeviceManagerClass();
}
public bool Refresh()
{
this._deviceManager.RefreshDeviceList();
// Determine how many WPD devices are connected
var deviceIds = new string[1];
uint count = 1;
this._deviceManager.GetDevices(null, ref count);
if (count > 0)
{
// Retrieve the device id for each connected device
deviceIds = new string[count];
this._deviceManager.GetDevices(deviceIds, ref count);
foreach (var deviceId in deviceIds)
{
Add(new PortableDevice(deviceId));
}
return true;
}
else
return false;
}
}
I can create the dll with visual studio and use this inside of the delphi application. When the delphi application calls the getDevices() function, i get an error on the instantiation of the PortableDeviceCollection class:
The file or assembly "Interop.PortableDeviceApiLib, Version = 1.0.0.0,
Culture = neutral, PublicKeyToken = null" or a dependency of it was
not found. The assembly is created by a runtime that is more recent
than the currently loaded runtime and can not be loaded.
ProductXY.PortableDeviceCollection..ctor()
ProductXY.ProductXYMain.getDevices()
The targetframework for the c# project is set to .Net Framework 4. Using any lower version i get an error when i try to compile the project:
The primary reference "Interop.PortableDeviceApiLib" could not be
resolved because it has an indirect dependency on the .NET Framework
assembly "mscorlib, version = 4.0.0.0, Culture = neutral,
PublicKeyToken = b77a5c561934e089", which is a higher version 4.0.0.0
than version 2.0.0.0 in the current target framework.
Please note. I have neither written the c# library nor the delphi application. Both have worked together for years. Now i have to add a functionallity to the c# library. I have not added any code to the project. I just tried to compile it again and use the dll. The only thing i did was updating the RGiesecke.DLLExport.Metadata via NuGet Packetmanager. Without updating i got an error
"Microsoft.Build.Utilities.ToolLocationHelper could not find
ildasm.exe"
I am aware of this Enumerating Windows Portable Devices in C# question. But my error is thrown before the code which is treaded by the question is reached. I still tried the solution to the question, but the action (deassamble, find and replace in the dll) which is described in the answere has already been done (otherwise my code would not have compiled).
The error message doesn't make sense to me. Interop.PortableDeviceApiLib is a COM-Lib which is not available for download in different framework-versions. I think I am missing something here.
Can anyone help me?
I was finally able to solve this problem. To be honest I don't know what finally solved this. For every one who stumbles up on this, here are the things i tried to fix this problem. They are in no specific order (since i tried everything multiple times):
Updating the RGiesecke.DLLExport packet
Changing the plattform in the Konfigurations-Manager to x86
Disassamble, edit and reassable the Interop.PortableDeviceApiLib like in this question (answeres of Christophe Geers and Bruno Klein)
Delete the reference to the Interop.PortableDeviceApiLib
Delete the reference to the Interop.PortableDeviceTypesLib
Readding the reference to the Interop.PortableDeviceApiLib
Readding the reference to the Interop.PortableDeviceTypesLib
Rebuild the project
Setting the Interoptyp embeddet on both to false (I found various statements to NOT do this, but the project was set up like this when i got it and it worked (be carefull)) on both Interop-Libs.
At least this helped me.
There are a lot of questions floating around with this problem and i've worked through them ll with no joy.
I am receiving this error:
Method 'get_UserImageCDNUrl' in type 'App.Web.WebConfig' from assembly
'App.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does
not have an implementation.
Which is really strange because I am trying to run Api.Web which has no reference to App.Web, the only thing they have in common are references to other projects (Models.Domain and Models.DTO).
I have an interface:
IResourceCompiler in an assembly "Models.Domain"
I have an abstract class which implements this interface in the same assembly (Models.Domain) called WebConfigBase
In the "App.Web" and "Api.Web" projects they each have a class called WebConfig which inherit from WebConfigBase, therefore both WebConfig classes in App and Api are implementations of IResourceCompiler.
I tried to add a property
string UserImageCDNUrl {get;}
to IResourceCompiler and added the property to WebConfigBase
public string UserImageCDNUrl
{
get { return ""; }
}
so the property would be accessible to both Api and Web projects through their own WebConfig classes, and i get the exception above.
I have looked for hours to try and see why this happens with no joy.
I've cleared my Obj folders, cleaned, rebuilt, checked for any instances in GAC (there aren't any) and i'm still stuck on this.
Everything works fine until i try to add a new property to the interface (and base class)
OK, so bizarrely adding a reference to App.Web in Api.Web and removing it again has solved the issue.
I have no idea why, but it did.
I changed the version of App.Web to 1.0.0.1 and the error was still showing 1.0.0.0, which is what prompted me to do it.
I wish there was a more reasonable explanation but there isn't. Such an infuriating issue i'm just glad to be done with it.
Best of luck to anyone else who experiences this, my thought's are with you
For the records, in my case this was caused by two projects referencing different versions of the same package. At least fixing this solved the issue.
There can be many reasons for this, all the previous answers represent a case of this problem.
What I suggest doing is:
while your program is running open Resource Monitor -> CPU tab and in the search handles input box, search for the assembly that supposedly doesn't implement that method.
In the search results you'll see the path of your assembly, and most likely the path that you see isn't the one that you expect. Delete the assembly from this unexpected path so that the correct assembly gets loaded.
In many cases I become this error.
It seems like Cached assembly and I found them in UserProfile.
My solution is:
Save solution and close Visual Studio
Delete entire folder "c:\Users(user)\AppData\Local\Microsoft\VisualStudio\14.0\ProjectAssemblies\"
Start Visual Studio
Work...
Hope it helps.
I just remove the reference of current project (which is showing error) , and add again to other project in which project this was referenced build and it start working fine.
hope this help someone.
try this
public interface IResourceCompiler
{
string UserImageCDNUrl {get;}
}
public abstract class WebConfigBase : IResourceCompiler
{
public abstract string UserImageCDNUrl {get;}
}
public class WebConfig : WebConfigBase
{
public override string UserImageCDNUrl { return "whatever you want";}
}
or that way too:
public interface IResourceCompiler
{
string UserImageCDNUrl {get;}
}
public abstract class WebConfigBase : IResourceCompiler
{
public virtual string UserImageCDNUrl {get { return string.empty;}}
}
public class WebConfig : WebConfigBase
{
public override string UserImageCDNUrl { return "whatever you want";} // or return base.UserImageCDNUrl ;
}
I was seeing this problem in Visual Studio 2017.
Upgrading to visual studio 2019 solved the problem for me.
I am trying to create an automation system but I am facing a problem here. Below is the brief description
main.cs
[Test]
public void Test_MyPage()
{
LoginPageObject objLogin = new LoginPageObject();
FunctionTest cc = objLogin.FunctionAbcTest();
FunctionTest objAbcTest = new FunctionTest();
}
LoginPageObject.cs
// Login Functionality
//public void Login (some args){...}
// And
public FunctionTest FunctionAbcTest()
{
//some functions to be called .....(1)
return new FunctionTest();
}
FunctionTest.cs
//Test automation functions are called
Expected Result: To return to FunctionTest class to continue further test
Actual Result: After some function which is called in (1) it automation gets completed but does not return to FunctionTest.cs
I really need help with this.
I would really appreciate your help.
PLEASE NOTE:
For more description, you can refer my project.
Click Here.
Please add full path to open excel file
Install MS Access Database engine 2010 (either 32bit or 64bit depending on your machine).
Install nunit 2.6.4 and run the project via nunit
Visual Studio 2013
Download will expires 1/3
In your main.cs you need to add one line.
[Test]
public void Test_MyPage()
{
LoginPageObject objLogin = new LoginPageObject();
FunctionTest cc = objLogin.FunctionAbcTest();
FunctionTest objAbcTest = new FunctionTest();
objAbcTest.SpeedTest();
}
Also change your Xpath to
[FindsBy(How = How.XPath, Using = "//div[#id='cssmenu']/ul/li[3]/a/span")]
public IWebElement UserForm { get; set;}
This will solve your problem.
And I think the site you have chosen is to use as an example to show why your function is not working. Probably, your original site id different. And it does not seems to be homework.
Please do let us know whether it worked or not.
Best of Luck in scripting your further code.
I have the simplest of apps that I thought I would try on my device before I got too engrossed. However, I am getting the strangest error message when I run it on my iPhone (as apposed to the the emulator on my macbook).
Table has no (public) columns .
I am using the SQLite.Net PCL and I have built it from git hub as I had some problems with it not having the platform dlls for IOS otherwise.
Relevant code.
In my models I have this:
public class Setting
{
[PrimaryKey, AutoIncrement]
public long Id { get; set; }
[Indexed]
public string Key { get; set; }
public string Value { get; set; }
}
The code that throws this error message is the simple:
using (SQLiteConnection db = GetCon ()) {
db.CreateTable<Setting> ();
}
but in my opinion the strangest thing is that this code works fine on the emulator but crashes the application on the iphone itself.
If anyone has some ideas that would be great.
EDIT:
This error is thrown on the SQLite.Net-PCL library on this file line 380 but only on the device and not on the emulator.
For others to whom this may concern, I found the answer to my problem. The issue was with the Type not having any properties (the type in question the simple model class). Knowing that to be rubbish I found the following links that gave more information which I will relate in this post in case the links go dead:
Type.GetProperties returning nothing
NOTE: Be careful with assembly linker
If you're building with linker enabled you may need to use the class
somewhere, so it will not be ripped off at compile time. Sometimes,
only instantiating the class in your code is not enough, the linker
may detect that the instance is never used and will remove it anyway.
http://developer.xamarin.com/guides/ios/advanced_topics/linker/
The linking process can be customized via the linker behavior
drop-down in Project Options. To access this double-click on the iOS
project and browse to iOS Build > Linker Options, as illustrated below
(see link for details)
I have for now left it to be unlinked, however, I will try before release to get the linker to ignore these classes. Thanks for all your help.
I found my problem was just a (not that subtle) programming error. I was working with the TypeInfo class and wanted to use the Sqlite Connection method:
CreateTable (Type type);
What I had in my hand was a TypeInfo instance which I needed to convert back to the System.Type. I accidentally without thinking used the GetType() method instead of AsType() method which is obvious when you think about it. The clue I got was in the exception message along with the OP message was does System.Runtime have public properties?
var type = table.TypeInfo.AsType();
// var type = table.TypeInfo.GetType(); *WRONG*
connection.CreateTable(type);
Initially, I think PowerShell instantiate one class only when the cmdlet tagged on this class is called. On execution, each cmdlet falls into the BeginProcess -> ProcessRecord -> EndProcess(StopProcess) path, and after the EndProcess is done, it seems the process will end and then the memory will collect all these class objects as garbage.Therefore each class should live in their own life cycle and not share any resources. When we are calling these cmdlets,
However I find that classes do share the same static values in the same module. For example, assume in my project I have two classes:
namespace PSDSL
{
[Cmdlet(VerbsCommon.Get, "MyTest")]
public class GetMyTest : Cmdlet
{
public static GlobalUserName = "";
[Parameter(Mandatory = false)]
public string Filepath { get; set; }
protected override void InnerProcessRecord()
{
if (_filepath != null)
{
GlobalUserName = _filepath;
}
Console.WriteLine(GlobalUserName);
}
}
}
namespace PSDSL
{
[Cmdlet(VerbsCommon.Get, "MyTest2")]
public class GetMyTest2 : Cmdlet
{
[Parameter(Mandatory = false)]
public string Filepath { get; set; }
protected override void InnerProcessRecord()
{
if (_filepath != null)
{
GlobalUserName = _filepath;
}
Console.WriteLine(GlobalUserName);
}
}
}
The two commands are pretty similar except one defines a static GlobalUserName. Calling these 2 cmdlets shows that the GlobalUserName can be read\write from both cmdlets.
My confusion is that, when are the classes be instaniated?
Whole assembly loaded at once and stays loaded till restart of the PowerShell prompt.
Details:
Smallest unit of code isolation in .Net is Assembly (in most cases single managed DLL).
Process that uses managed runtime can't load less than single assembly at a time - so all classes from that assembly (and related once on demand) will be loaded together. As result all static fields will be present at the same time in memory (note that static fields are initialized "before first use of the class" which mean they are not necessary initialized on load of the assembly).
There also no way to "unload" class or even assembly without using separate AppDomains. PowerShell does not use multiple AppDomains to load assemblies for different modules (generally cross-AddDomain calls require special attention during implementation and you'd know about it by now). As result once loaded module stays in memory till you quit PowerShell (covered in Powershell Unload Module... completely).
Since assembly is loaded once for all commandlets in it all static fields will be present at once and keep they values till exiting of PowerShell.
Side note: I'd strongly recommend avoiding static fields for anything but really static immutable data in general. It is way to easy to leave some random values there and impact future code. In PowerShell pipeline is the way to pass information between commandlets, other types of processes (WinForms, ASP.Net,...) have they own preferred mechanism to pass data instead of using static.