I'm busy on a small project to convert an Access2003 db to .NET. I am trying to integrate my functionality in an existing project that is being used for Administration of some kind. The code in this project is VB.net.
I started by setting up my Data Access Layer, which seems to work fine. I can make new web pages that access the data I need. However when I start to use class files to set up my Business Logic Layer I can't build my project when using C# instead of VB. I dislike VB and like to program in C# as I know the syntax a lot better, etc. Is it possible to program using C# knowing that VB.NET was the language chosen to build the entire project on?
If not, what will be the smartest way to integrate my module into the project using my favorite programming language? (Make a project and reference to the dll?)
Edit: So the next step in my question would be -->
If I set up a new project within the existing solution, can I make that new project contain my Business Logic Layer + Data Access Layer and reference from my existing one?
Yes, you can't mix languages within the same project, but you can add as many projects written in different languages as you like, to the same solution. (This is sometimes very useful, especially when it comes to having portions written in C++/CLI, which are able to do things which would be impossible to do in C#/VB.NET.)
Related
So I am trying to get more knowledge on the Architecture/Infrastructure of an application and want to build simple applications, just to learn.
So what I was wondering is the following:
If I have multiple applications which have functions that are almost same in every application, how can I move this code to 1 place and let all applciations use it.
Let's say the way of logging in. You preferably want to build it one time and maintain it at one place. All updates should be done in one place.
Should I use an Api, nuget, shared library or something else?
The database for each application should be different.
This is a general question, but I am coding in C# .net
I've been trying to find some clear documentation on best practices with regard to nesting Visual Studio solutions. Please bear with me if the terminology is wrong - I'm not really experienced in creating significant solutions.
Here's what I'm trying to achieve.
I have a website that is a web application in VS speak - so it is my solution.
The site will have some reusable functionality. Normally I would just create a class library project and have done with it.
However, in this case the functionality is database driven via Entity Framework. If I was creating a self contained project, I would create a new solution, containing 3 library class projects for BLL, DAL and Entities.
So instead, I'm thinking a second solution containing the 3 class libraries - obviously I don't need a second front end as the primary web application will do the job.
So, I have a number of options as far as I can see:
Create a new solution as described above that can be plugged into my
main solution - but what do I do with the unwanted project that
contains the App_Data, Account folders etc?
Create a single class library and create visual separation through
folders.
Create 3 separate class lib projects (although this gives least
benefit)
Or, something else I'm not aware of.
Sorry if this sounds basic to you guys that do this day in day out, but I just don't have the necessary experience to make the right call.
I'd like some help in how to add scripting support to a WPF C# project I'm doing on Visual Studio 2015. One of the things I'd like to do is to be able to change User Control properties within that script. I've being trying Roslyn C#, and I read some stuff about IronPython and PowerShell Tools. But, all that information is not really helping.
So, do you have a simple answer? Like, the easiest way to execute scripts in Visual Studio 2015 C# WPF Application, that are able to change properties of User Controls within the project?
Any help would be appreciated.
Thanks,
Lucas.
T4 templates can help but they are less extensible than lets say Roslyn.
I found a great post on how to easily implement IronPython and how to access User Controls within the scripts in Python, so you can there change different Control properties, and even create them! Here's the link:http://www.codeproject.com/Articles/602112/Scripting-NET-Applications-with-IronPython
I think it should be quite simple to embed powershell or F# interactive in an application and there are lots of examples when we search the web for this. The question is only are we comfortable writing scripts in Powershell and F#?
In my application I provide a C# editor and compile scripts as static methods (which I uses as functions) using the standard .Net compiler API's which are installed with the framework (Microsoft.Csharp, System.CodeDom). This generates a temporary dll and perhaps can not be properly termed a script. The implementation is straight forward and more or less what you expect - I have to provide a way for the users to specify references and namespaces, then generate a source file, compile it to an assembly and then call members of the static class. This above technique works well because the application has extension points that are well adapted to user defined code with a certain well defined structure (you might have similar well defined needs and perhaps full scripting is not necessary).
On the other hand, I am considering providing a "super user" console where the application can be driven by script, and in this case, I will use either Powershell or F-sharp interactive (I'm leaning towards F#). I don't think the implementation is particularly complex, but these are things that can easily bring the application down or corrupt application data if it is not well controlled - and it is unlikely that my users will profit from scripting as it is a programmer environment.
I am currently writing my GUI program in C++/CLI. (I know, not good. And I am not sure about it ever since I first thought about switching to C#. Another Question of mine).
Another question here that might convince me is, if there is anything compareable to the Settings-Designer in C# that I can use in C++/CLI. I got it working with my own implementation of the Settings-class but it is kind of error-prone. So, are there any designers or functions I can use in C++/CLI to make the app- and user-Settings management easier?
No. The missing feature in the C++ IDE is the code generator that auto-generates code from the setting designer. Microsoft just never invested the energy to create the VS add-ins required to support it, code generators like this were only implemented for the VB.NET and C# IDEs. Multiple reasons for that, a bit beyond the scope of this Q+A.
You can still use the settings designer, you just have a jump through a few hoops. Empowered by the excellent support for language interop in .NET, you can simply add a C# class library project to your solution. Then Project > Properties > Settings > click Create. On the toolbar, change the Access Modifiers combobox from Internal to Public so your C++/CLI code can use them. Add your settings as usual.
Add the project reference to your C++/CLI project and you can now use ClassLibrary1::Properties in your code just as you would in a C# app. Just a different namespace.
One more hoop, saving the tricky one for last, you have to copy the app.config file from your C# project to your C++/CLI's build directory. Use xcopy in a post-build event to do that, final name must be yourcppapp.exe.config. God help you if you have to merge other .config settings, that's very hard to automate. Fwiw, best to go with the flow, you are in C++ land now. It is supposed to be hard, otherwise anybody could do it :) Settings only work for small monolithic LOB apps anyway, not the typical C++ target.
I've a Web Application project that uses VB as programming language. I want to keep using this language due I've more experience and also it works better with IntelliSense.
Anyway, now I am using Open XML SDK 2.0 Productivity Tool for generate code for the generation of a OOXML document through a given template, and this tool only generates C# code.
With the aim to mix both languages in my project, I had followed this tuto but when I try to add a new C# class, the only language that appears in the list is Visual Basic as you can see in the attached screenshot.
Does anyone know how I can fix this?
Thank you very much
This is not possible; you cannot mix C# with VB.NET in the same project. When .NET compiles an assembly it can use only one compiler to do so.
What you can do, is have a solution with multiple projects (for instance one Web app and several class libraries), and then you can have each class library in the language of your choice.
As others have said in general you cannot do this. The one exception is a web site project.
There is a difference between a web site project and a web application. Mainly in the way they are compiled. A web site is what the tutorial you linked talks about (note the way they say to create it via new website rather than new project and choosing web app) whereas you say above that you have a web application.
You have the option of either changing to a web site or using supplemental projects as others have suggested.
Mixing languages is not what I would go for.
Add a new (DLL)project to your solution that uses C# and handles your XML.
Reference that C# project from your VB-app and call into it.
Clean and easy.
You need to install Visual Studio for c#. It looks your current installed language is vb.
Here is link for downloading vs:
http://www.microsoft.com/visualstudio/eng/downloads#d-2010-express
About using vb and c# code in same solution, its possible as long they are separated to different projects.