Not able to find AssemblyFactory class using Mono.Cecil - mono.cecil

I am using the Mono.Cecil DLL file and writing this code:
AssemblyDefinition sourceAssembly = AssemblyFactory.GetAssembly(assemblyPath);
My project is not getting compiled, because it is not able to find the class "AssemblyFactory". As if this class is not present in the DLL file at all. I have added the mono.cecil.dll file as a reference to my project. Is this class present somewhere outside the DLL file, maybe in some other DLL file at the .NET level?

This simply means that you're using an up to date version of Mono.Cecil where this deprecated type has been removed.
Please have a look at the migration page on Cecil's wiki to know how to convert code for Cecil 0.9. You'll see that you just have to change this line to read:
var assembly = AssemblyDefinition.ReadAssembly(assemblyPath);

Related

RoslynPad: could not load file or assembly exception

I am using RoslynPad project to test how external plugins (Class libraries) could be used in the script.
I have created Class Library with a single class and method.
In roslynPad project i have added "plugin_demo" into RoslynHostReferences NamespaceDefault structure.
I have also added reference to plugin dll:
MetadataReference newref = MetadataReference.CreateFromFile("G:\\projects\\demos\\plugin_demo\\plugin_demo\\bin\\Debug\\plugin_demo.dll");
MetadataReferences = MetadataReferences.Add(newref);
Now i see that my new class is seen by diagnostics and autocomplition also works.
The code with a method call compiles fine.
But when i run it i get exception:
Could not load assembly or file. File not found.
I have copied plugin_demo.dll into directory where compiled roslynPad dll resides. Still no result.
I have checked that class library and roslynpad use the same .Code version.
What can be the problem?
What is correct way of adding assemblies to roslyn project?
Thanks
I have solved the problem after debugging. The roslynPad project generates file nams_deps.json when editor is launched. It must be deleted and after that the assembly is found.

VS CShellManager not declared

I have downloaded an API to further develop it and this error appears: C2065 CShellManager not declared. I guess it might be declared in a library which is not included by default, but it should be in the zip I have downloaded. How can a look for the declaration of this class in order to know the file in which is declared and to include this library in the source code?
The CShellManager class is a part of MFC framework. It is defined in afxshellmanager.h header file.
This class was introduced in VS 2008 as part of so called MFC Feature Pack.
Basically it is only required if your project uses CMFCShellTreeCtrl and such. If this is the case then you need to call CWinAppEx::InitShellManager() in OnInitInstance() of your app class to initialize the instance of the Shell Manager.

How to use ReaderWriterOBJ in OpenSeneGraph

Can anyone explain to me how to use ReaderWriterOBJ in OpenSceneGraph? I want to load an obj file along with the mtl file. I have already built the solution for readerWriterObj code and created a dll file.
The ReaderWriter's are just file loaders. You have to use them in context of an application, like osgviewer, one of the examples included in OSG. If you've gone through the process of building OSG, you might have already built osgviewer, which will use the appropriate DLL's to load files.
eg
osgviewer FILE.obj
will open FILE.obj, with its associated material file[s].

Using a SharpDevelop library, how do I add a reference to a project?

I'm using ICSharpCode.SharpDevelop libraries for my project. I'm trying to figure out how to construct an instance of DefaultProject so that it has all necessary references. So, I need something like
projectContent.AddReferencedContent(_projectContentRegistry.GetProjectContentForReference("System.Core", "System.Core"));
Except that it doesn't work -- GetProjectContentForReference(..) always returns null, whatever I'm trying to provide for the arguments.
It looks like a bug in the ProjectContentRegistry class in SharpDevelop 4.x. If you debug the GetProjectContentForReference() method then you can see it is looking in the wrong GAC folder. It is looking in the folder
System.Core\4.0.0.0__b77a5c561934e089\System.Core.dll
when it should be looking in the folder
System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll
I suspect this bug has not been noticed since SharpDevelop now uses MSBuild to work out the location of assembly references. With System.Core for example it will find the assembly in the reference assemblies folder based on the project's target framework:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Profile\Client\System.Core.dll
What you can do instead is find the filename using the GacInterop class that is part of the ICSharpCode.SharpDevelop.Dom assembly. The code below should return a non-null project content object.
var reference = new DomAssemblyName("System.Core");
reference = GacInterop.FindBestMatchingAssemblyName(reference);
string fileName = GacInterop.FindAssemblyInNetGac(reference);
var registry = new ProjectContentRegistry();
IProjectContent pc = registry.GetProjectContentForReference("System.Core", fileName);

How to use tlb files in a native C++ project

I have a tlb files that contains some function declaration that I need to use.
If I use
#import "type_library.tlb"
I can correclty reference the function from my code:
tlb_namespace::required_function();
But when I compile the project the linker says that tlb_namespace::required_function is an unresolved external symbol.
How can I succesfully build this kind of project?
EDIT:
I have used the same type library in a Dummy VBA access project. I have added the reference to the type library and I have noticed that some of the function contained in the type library are correctly called. But some of them are not. VBA says It can't locate their entry point in the related dll.
Can this explain the unresolved external symbol when building c++ app?
I have also noticed that the failing function are declared in the tlb like this:
UPPER_function_name
but in the dll are declared like this:
Upper_function_name
Can this be the issue?
Is it possible to solve this kind of error directly modifying the binary tlb file or dll?
Use IDE to view TLB information.
Use this help : How to: View Type Library Information
At IDE : View-> Object Browser, click "..." Edit Custom Component Set, browse your TLB file and Add to view information.
Confirm namespace used for.
use the namespace to resolve the linker error:
example:
#import "<>" raw_interfaces_only
using namespace <>
this will resolve the problem

Resources