I have a number of very useful extension methods that I'd like to use in my Silverlight project.
I've pasted the Module here http://pastebin.com/TfBpNDWr
The problem I'm having is that visual studio complains that the dlls my module have been written against have not been built against the Silverlight runtime.
Is there an easy way to get these extension methods working in Silverlight?
I'm thinking my main hurdle is getting IObjectSet and ObjectContext to run against the Silverlight run-time - perhaps there's another way to expose these methods that I'm not aware of.
When you want to reuse code in such way, there are these three options I'm aware of:
Generally create all your basic class libraries as a Silverlight class library project, or, more officially, as a Portable Class Library. Throw all references out except for mscorlib.dll, System.dll and System.Core.dll. You can then link such kind of library in any full .NET project.
You can link individual code files from another project with the "Add as link" feature (Right click project -> Add Existing Item -> Change "Add" Button to "Add as link"). That way you can create a Silverlight project and link individual files from your full .NET project. However that can get tedious if you have a lot of files and you often add/remove files and folders in your source project.
To cure this problem, you may check out the Project Linker at http://msdn.microsoft.com/en-us/library/dd458870.aspx ... but I haven't tried it myself yet.
Related
Never have known if this is even possible - and if so - how?!!
But I have our MFC applications separated out into the exe project, and a set of associated resource-only .dll projects, one per translation.
We only need to maintain English, and then parse the resources using a 3rd party translation suite to extract translatable strings, get them translated, and then constitute a translated resource .dll project for shipping.
It's a neat coherent system but for the fact that I cannot use MSVC's built-in MFC editors to connect up visual interfaces back to the correct code in the .exe project files.
If I try to use the resource editor to - e.g. generate an MFC Dialog subclass as the code-behind for a given Dialog resource - then the MSVC environment tries to create such files in the resource .dll project - which is wrong and unhelpful.
Does anyone know of a technique to get a given resource project to say "Hey - all of my code-behind should be in this other project over there?
I wanna use the C# code file in VB.Net project Which is windows based application. But that C# class is not using in VB.NET application. How Can I perform this task.
Thanks
Compile the C# class in it's own C# class library (DLL) and then in your VB project, add a reference to the C# DLL. You can then use the class in your VB project.
If, however, you want to include the source code of the C# class in your VB project then you will have to convert the class from C# to VB. There are various methods of doing this, such as the online tool Convert C# to VB.NET
It is very simple to combine your VB.net & C#.net project.
Step1- Add projects which you wanna combine to a single solution.
Step2- Within any one project VB/C# in which you want to call classes from other language project "Goto- Add Reference- Projects" and select the other project which will be automatically displayed.
Step3- After adding the reference just add "Imports (in VB)" or "using (in C#)" statements to your code.
Step4- bingooo!!! now you can use your VB/C# classes in another language.
(tip: You can go only in one direction here i.e. either you can use your C# classes in VB.net or vice versa.)
All the best
You can also add the reference for an executable, if it is a .NET assembly. So just compile your C# project and add it as reference into your VB project.
It is possible, check this:
http://bytes.com/topic/net/answers/49259-mixing-vb-net-c-same-project
However, it is possible to use
different languages in a single
project. You may need to write command
line build file to build the project.
In .NET framework SDK, there is one
sample on it. You could access it in
C:\Program Files\Microsoft Visual
Studio
.NET\FrameworkSDK\Samples\Technologies\CrossDevLan
guage.
This sample demonstrates the use
different development languages in a
single project. This sample creates
two assemblies. The first is a library
or DLL assembly that defines a simple
base class written in managed
extensions for C++. The second
assembly is an executable assembly
that defines three derived classes
written in C#, VB, and IL
(Intermediate Language). These types
derive from each other and ultimately
from the base class written in managed
C++. Finally, the executable creates
instances of each of the derived types
and calls a virtual method for each.
The .NET Framework is an environment
where various developers can work
together seamlessly while developing
in their language of choice.
I have a working Windows Forms app (split into an EXE and a few DLLs). Now I've been asked to look at creating another app (MyAppLite) that has only a very small subset of the functionality. Think of it as similar to MS Word Viewer vs. MS Word.
Everything that I need to build MyAppLite is contained in the main solution - essentially I need to use a couple of the WinForms and whatever bits in the DLLs they call into.
What would be the best way to do this?
I was thinking of creating another Project in my solution for MyAppLite, then adding the necessary source files as links (using Add Existing Item > Add As Link in Solution Explorer).
I definitely wouldn't want to maintain 2 copies of the source code.
FYI it's a .NET 2.0 VB app, using VS2008.
You can create a new class library to contain your forms that are common to both projects. Create the new project and copy the forms from the original project into the new class library. Then you can import the class library into both the original project (after removing the original versions of the forms) and the MyAppLite version. If you need to change the forms, change it in the class library and then recompile your applications
You could refactor your project so that it would keep the common functionality in a MyAppCore project, and reference that from both MyApp and MyAppLite. The core dll would contain all the common functionality and take parameters as to what to allow and what to restrict, so the set of features in your lite version is customizable(say you have a customer that reaaaallly wants a preview of a certain feature).
I wanna use the C# code file in VB.Net project Which is windows based application. But that C# class is not using in VB.NET application. How Can I perform this task.
Thanks
Compile the C# class in it's own C# class library (DLL) and then in your VB project, add a reference to the C# DLL. You can then use the class in your VB project.
If, however, you want to include the source code of the C# class in your VB project then you will have to convert the class from C# to VB. There are various methods of doing this, such as the online tool Convert C# to VB.NET
It is very simple to combine your VB.net & C#.net project.
Step1- Add projects which you wanna combine to a single solution.
Step2- Within any one project VB/C# in which you want to call classes from other language project "Goto- Add Reference- Projects" and select the other project which will be automatically displayed.
Step3- After adding the reference just add "Imports (in VB)" or "using (in C#)" statements to your code.
Step4- bingooo!!! now you can use your VB/C# classes in another language.
(tip: You can go only in one direction here i.e. either you can use your C# classes in VB.net or vice versa.)
All the best
You can also add the reference for an executable, if it is a .NET assembly. So just compile your C# project and add it as reference into your VB project.
It is possible, check this:
http://bytes.com/topic/net/answers/49259-mixing-vb-net-c-same-project
However, it is possible to use
different languages in a single
project. You may need to write command
line build file to build the project.
In .NET framework SDK, there is one
sample on it. You could access it in
C:\Program Files\Microsoft Visual
Studio
.NET\FrameworkSDK\Samples\Technologies\CrossDevLan
guage.
This sample demonstrates the use
different development languages in a
single project. This sample creates
two assemblies. The first is a library
or DLL assembly that defines a simple
base class written in managed
extensions for C++. The second
assembly is an executable assembly
that defines three derived classes
written in C#, VB, and IL
(Intermediate Language). These types
derive from each other and ultimately
from the base class written in managed
C++. Finally, the executable creates
instances of each of the derived types
and calls a virtual method for each.
The .NET Framework is an environment
where various developers can work
together seamlessly while developing
in their language of choice.
I am very new to VB.net. I have written these objects in VB6 before. I'm just lost in VB.net, but (kicking and screaming) I have to learn how to do this. I've been googling for hours with only minor steps forward. Can anyone post a link that explains start to finish how to do this?
I have managed to write the class object, What I can not tell is how to register it and where the name1 and name2 in the CreateObject("Name1.Name2") come from.
Regsrv32 will not work. It says "Entry Point not found" and will not register it. Also, I can not drop it into the Assemblies directory. I read something about a regasm command one uses, but I can't seem to make this work either.
Thanks in advance for any assistance.
I am going to assume you are not trying to write a COM DLL but rather a complete project that call various sub assemblies like a VB6 EXE call a ActiveX DLL. If you can be more specific about what you are trying to do it would help me better.
Several points about VB.NET versus VB6.
1) For .NET only projects there is no registration. If a EXE or DLL references another .NET DLL the only requirement is that the DLLs be present in the parent's directory.
2) You can do a COM style registration for .NET apps only by registering the .NET assembly in the GAC. However there are several requirements for doing this. Do a search on the .NET GAC and it will give you the scoop on how to do this.
3) You can setup the .NET assembly to use COM in which case it will operate by the rules of COM including registration with regsvr.
You will find for .NET only project that #2, or #3 only come in rare instances. #1 will apply for 90% of your DLL assemblies. Of This is dependent on your project.
A common use for CreateObject is allow for plug-ins or installable libraries. .NET handles this through the Reflection API. With the reflection API you can look in a directory, go through each .NET DLL and see what them and create objects from what you find. Search for .NET Reflection to read up on this.
If your project is .NET only then I recommend that you create a Assembly that is reference by both the master assembly and the individual sub assembly that define the interfaces of the objects you are creating. This when you use the reflection API and determine the Object type you can assign it to a variable of that interface and code it noramlly with intellisense and other aids.
if you have old COM ActiveX Controls or DLLs .NET will generate a wrapper class that exposes the ActiveX Objects to .NET. I would spend some time learning how .NET does this. What I do create a dummy project and have .NET reference the ActiveX stuff I need. I then find the wrapper projects and DLL it made and move them into a central area. That why when I work on subsquent projects using the same ActiveX stuff I know where all the wrappers are.
You have to go to your class library properties and select the option "Register for COM interop". This will make your assembly available to COM.
You want to create what's called a COM Callable Wrapper (aka CCW) for your .NET component. This basically entails setting up some COM interfaces with some GUIDs and either enabling "Register for COM Interop" in the project properties (as mentioned) or using regasm.exe.