I have been given dlls for entities, service classes. I need to add additional properties to Entity in my web project. How can I do that? I cannot create new classes extending dll classes because service dll returns Entity class defined in the dlls.
Is there any way?
thanks
Sanjivani
Related
I have a visual studio solution with a couple of C# projects. One of them contains my domain classes and has no infrastructure dependencies and another contains classes that depend on various 3rd party libraries, it's what you'd call an infrastructure project.
For each class in my domain project I have to write a corresponding class in my infrastructure project which contains just some boilerplate code required for using a feature of one of the 3rd party dependencies so I'd like to generate that automatically whenever my domain class is changed.
I was able to generate the classes containing this boilerplate code by creating a source generator with a ISyntaxReceiver that adds the abstract syntax tree of my domain classes for which I need to generate the boilerplate code to a list which is then used by my source generator to create the required classes. I then added this source generator as a project reference to my domain project but I have a problem: the infrastructure classes I need to generate inherit from a class of a 3rd party dependency so I have to add that 3rd party dependency to my domain project.
What I tried to do was to add my source generator as a project reference to my infrastructure project (which already references the 3rd party dependency, and also my domain project) but the source generator does not run because the ISyntaxReceiver's OnVisitSyntaxNode method does not get called for any of the classes in the referenced domain project.
Does anyone know if it's possible to create a source generator that generates code based on classes in projects referenced by the project that references that source generator?
I am aware of the AnalyzerAdditionalFiles, but seems like that should be used for making generation decisions based on more than just C# code
I have a Solution which consists of two projects - the Manager and Viewer. Naturally, both use the same classes, e.g. Manager is used to edit data in SomeItem class instances, while Viewer is used to display it's data.
I have all class definitions in the Manager project. To use them in the Viewer project, I created the same directory hierarchy in the Viewer and linked all classes with build action set to "Compile".
But now I'm getting tons of warnings like this:
The type 'SomeItem' in 'Manager\Classes\SomeItem.class.cs' conflicts
with the imported type 'SomeItem' in 'Viewer, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null'. Using the type defined in
'Manager\Classes\SomeItem.class.cs'.
What is the best way to use the same class in two projects while having it in a single file?
I would suggest that you create a separate project with the classes you want to have in common, set application type as Class library, after doing this and compiling it you will be able to add it as a reference to both of your other projects by right clicking on references and adding it as a project reference.
I have WCF service responsible for exposing services and connecting with local database MSSQL.
I generate client of this service in a few projects, e.g. Proj1 and Proj2. In Proj3 I have references to Proj1 and Proj2. I want to use types from database, but they are in different namespaces (Proj1.ServiceReference.TablePerson, Proj2.ServiceReference.TablePerson).
How can I resolve this problem? I suppose using sth like converted/adapter for each type (table) is not the best solution.
Have a shared dll with your classes and reference it form the server and from the client.
When you create a wcf reference, make sure that "reuse types from existing assemblies" is set. This will make generated proxies rely on the shared dll code and WILL NOT create new proxy types each time you create a web reference.
What you should do is create a separate project to create your service references in, and then have Proj1 Proj2 and Proj3 all reference that project. That way you will only have to generate one set of classes for your service reference.
I have used Entity Framework for DAL in a few projects but in the one I'm working on right now, I have the edmx file in a class library project and that's all there is in the project. I have this project referenced in another class library project and for some reason I'm not able to access any of the entity classes that are defined in the .designer.cs file. I can't access the context class either. If i look at the referenced project in Object viewer in visual studio, it does not list any entities for this project.
Does anyone know why I'm not able to access the entity classes or the datacontext in another project?
EDIT: If it makes any difference, it's associated with a database on sql azure.
This is can happen into two different ways. One is to make sure the Entity Model class are public. The other is to check the Entity Model Namespace is matches to the Context class.
I was able to resolve it by deleting the existing edmx file and regenerating a new one.
Apparently the old one got into a weird state, I was not able to figure out how to get it to work again.
I have used Entity Framework for DAL in a few projects but in the one I'm working on right now, I have the edmx file in a class library project and that's all there is in the project. I have this project referenced in another class library project where i was not able to initialize the object for the entity class saying connection string was not set ,where i have checke with the connection string which was there.\
check your inherited class of DbContext, it must be public
Check the Namespaces of the Context class and Designer.cs class.
I have a solution in VS 2008 which has one web project and 3 Class libraries as 3 different Projects. One project is for DataAccess and one is for BusinessLogic.
I have a class in DataAccessLayer. From there when I am trying to access the Class of BusinessLogic class library (project) it is not coming in the IntelliSense when I type. I used the same namespace in both projects. Still same results.
Do I need to to create DLLs for the first project and add as reference to second?
You need to add reference to this project in another project in your soultion.
Visual studio has an option to add project as a reference, so you don't have to add assembly files directly
You need to reference the library in the other projects.
To do that, right-click the references folder in the Solution Explorer, click Add Reference, go to the Projects tab, and select the library that you want to reference.
EDIT: Also, make sure that the class you are trying to use is declared as public (eg, public class MyClass).
If you leave out the public modifier (which is the default), the class will only be usable in its project. To expose classes and members to other projects, add the public modifier to their declaration
You'll need to add a reference to the project containing the BusinessLogic class in the DataAccess project. Otherwise, the compiler doesn't have anyway of finding the implementation of your BusinessLogic class, even if it does use the same namespace.
This may sound silly, but have you specified the class in question as Public or Friend? They'll need to be "shared" in that sense in order to be properly picked up and used within the other applications, even when the project reference is specified.