How to share WinForms and code between 2 projects - vb.net

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).

Related

VB.NET how to prevent embedded images in the executable

I'm working in a VB.NET application using Visual Studio 2017.
I'm using a lot of images in my project and if I follow the instructions that I've found in the Internet (add images to a resource file) the executable ends up weighting more than 300MB. This is a huge problem because when I want to send updates to the users they have to download every time 300MB instead of just a few KB, and perhaps some additional images.
I would prefer the images to be stored separately from the executable, in the same folder, but this does not seem to be possible because using the resource file and building a release version they all get eaten inside the executable.
(Note that I need the images to show while working on the designer module, so it is not an option to load them all through code using image.fromfile, which would do exactly what I want)
Can someone point me in the right direction? Thanks a lot in advance.
You can create a separate class library project in the same solution. A class library project is compiled to a DLL. Include the image resources in this library project and add it as project reference to the main project.
If the image resources don't change, you don't need to re-distribute this DLL.
A trick that could enable you to use these resources at design time could be to use satellite assemblies for culture specific resources (I never tried it so). In your case you would have only on single culture.
See:
Locating and Using Resources for a Specific Culture (MSDN)
Localizing a Windows Application with Satellite Assemblies (article uses C# but should be the same procedure for VB).
How to Localize Windows Forms and Change the Language at Runtime

Creating your own library for use in window store dev (js) in visual studio

I am a javascript/html developer that hasn't ventured into visual studio much, so this might be a trivial question.
I am currently developing a Windows Store app (winJS), that will likely turn into several apps. And it would be highly likely that I will be reusing code, so I have made a js library with the common code.
The question is, how can I develop on this lib in visual studio, so that the apps that I am developing will use the latest version of it (i.e without me having to copy the files in again manually).
Best thing I can think of is, create a new project for the lib, and include it in the applications solutions, but what type of project would it have to be, and how to you expose the files?
Hope that makes sense!
Thanks!
I usually solve this by having the project copy the JS files I want to a common location, and add that file to the target project using a LINK to the file I want to include, rather than just adding it -- this is on the "Add Existing File" dialog, under the little arrow on the "Add" button.
VS 2012 doesn't have a JavaScript library project type. You'll have to manage your library as loose files.
The easiest thing would probably be to create a nuget package. That way it would be easy to pull into other projects and have the tool help keep you up to date. It does have the downside of needing to put your stuff into a nuget feed, which is not something you want for private stuff.

Silverlight - Useful extension methods in system.data.* namespace

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.

How to use Ext-designer to create UI for multiple pages?

In the example section in extjs4 official site, the source code is clean and direct (on a single page). However the ext designer uses MVC architecture that I am quite confused.
If I want to create UI using extjs 4, for multiple page, am I supposed to create multiple projects in ext designer?
I think these are two seperate questions '1. should I use MVC' and '2. Why does Designer NOT use MVC'.
In my opinion that answer to 1. should be 'yes' unless you project is relatively small and you feel comfy managing the entire codebase in one long file. This quickly becomes unmanagable and there is a lot of searching needed to locate the section you're after.
The answer to 2. is that designer is aimed to provide designers (funnily enough!) who often won't have any coding experience the ability to create prototypes and templates that developers can pick apart and build into applications. At least that was true with designer version 1.
I believe designer 2 is aimed much much at being able to directly port code into applications but if you're talking about version 1 I think you will need to take the code generated by the designer and move it into an MVC style structure in order to build applications which are anything more than a couple of simple pages.

how can I create DLL without having class

can anyone give me some steps to create DLL without using class which means it will just have methods in the header file and source file would be only DLLmain() plus other methods. I'm using Visual Studio 2005 to create MFC DLL, but it always generates class. I never create DLL before but I was told that I can create DLL without class/object oriented concepts, just plain functions.
thanks.
For a regular Win32 DLL:
In the New Project wizard, under Visual C++ / Win32, choose Win32 Project.
Then in the next page, choose DLL as application type.
You may want to select Export functions as well to get sample code of exported variables, functions and classes.
From there on, simply delete what you dont need (such as classes).
I no longer have the Windows Mobile SDK installed, but I'm pretty sure you'll find the same kind of wizard to create a Windows Mobile DLL project.
Of course, if you don't want C++ classes, forget about MFC!