473,229 Members | 1,856 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,229 software developers and data experts.

using duplicated class

Two assemblies both referenced by application contain same class (created by
script):

namespace Script
{
public class Class1 { }
}
Compiling application

class Program
{
static void Main()
{
var t = new Script.Class1();
}
}
causes error

The type 'Script.Class1' exists in both
'c:\myapp\Project1\bin\Release\Project1.dll' and
'c:\myapp\Project2\bin\Release\Project2.dll'
How to force compiler to use specific assembly, like

var t = new Script.Class1@",
Assembly=C:\Users\Andrus\Temp\TempAssembly.dll"
();

Andrus.

Aug 4 '08 #1
3 1352
On Aug 3, 7:17*pm, "Andrus" <kobrule...@hot.eewrote:
Two assemblies both referenced by application contain same class (createdby
script):

namespace Script
{
* * public class Class1 { }

}

Compiling application

class Program
{
* * static void Main()
* * {
* * * * var t = new Script.Class1();
* * }

}

causes error

The type 'Script.Class1' exists in both
'c:\myapp\Project1\bin\Release\Project1.dll' and
'c:\myapp\Project2\bin\Release\Project2.dll'

How to force compiler to use *specific assembly, like

*var t = new Script.Class1@",
Assembly=C:\Users\Andrus\Temp\TempAssembly.dll"
();
Go into Properties of each reference (in Solution Explorer, expand
References under your project, right-click on a specific reference,
and select Properties). There is a property called "Aliases" - change
it so that it is different for references to Project1 and to Project2
- simplest is just to use "Project1" and "Project2". Now you can use
the "extern alias" directive in the .cs file where you need to
disambiguate:

extern alias Project1;
extern alias Project2;

and disambiguate as needed using double-colon operator:

Project1::Script.Class1
Project2::Script.Class2
Aug 4 '08 #2
Pavel has given the answer to the specific question (extern alias),
but note that it is worth trying to avoid this scenario where-ever
possible. Perhaps consider making the namespace specific for each
script? So you have

Project1.Script.Class1 in Project1.dll
and
Project2.Script.Class1 in Project2.dll

Much simpler and more maintainable.

Marc
Aug 4 '08 #3
Marc,
Perhaps consider making the namespace specific for each
script? So you have

Project1.Script.Class1 in Project1.dll
and
Project2.Script.Class1 in Project2.dll

Much simpler and more maintainable.
I'm planning to allow end users to override entity objects for custom
default values and validation using scripting.
Custom entity classes are created dynamically by entity factory. For
example, user can create the following script:

namespace MyApp.Script {
public class Invoice : MyApp.Business.Invoice {
public override void OnCreated(object sender, CreateEventArgs e) {
// set default customer for new invoice
this.CustomerId = "123";
}
}
}

Another, Query creation script which returns only some properties which we
discussed earlier refers to this object by using "MyApp.Script.Invoice".

User can also modify script at runtime, for example change CustomerId to
"456".
In this cases entity factory creates new type but it has same namespace and
name:

After that compiler error occurs in query creation script since script
engine adds references to all assemblies referenced by application to
compiler.

Possible solutions:

1. How I can use global aliases or different namespaces in this case ?

2. Create all other class creation scripts so that they take entity type as
generic type parameter.
In this case application can pass entity to type created by script using
MakeGenericType()

3. Should I create Linq expression insted of script ? I need to modify your
earlier selected property selection sample but
I do'nt know how to make such modification.

4. Should I use delegates and static methods insted of entity class dynamic
override ?

5. Modify script engine to add reference only to latest entity assembly to
compiler.

I don't know which is best solution. I will try solution 2 first since this
seems to be simplest to implement.

Andrus.

Aug 4 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Alexander Kervero | last post by:
Hi ,today i was reading diveinto python book,in chapter 5 it has a very generic module to get file information,html,mp3s ,etc. The code of the example is here :...
3
by: Mirek Rusin | last post by:
....what is the best way to force duplicated unique or primary key'ed row inserts not to raise errors? duplicated rows can be ignored or updated as well - it really doesn't matter. to be...
1
by: Iain | last post by:
I'm struggling to create a typed data set (with xsd.exe) with 4 tables and 3 layers orders -> Items Items->ItemAtts1 Items->ItemAtts2 if you follow me. it's kind of working, but I don't...
0
by: Eric Chaves | last post by:
Hi Folks I'm tryingto use the EventLog class to wrote info on my own log (ie, not in Application). If I use the same text for Source and LogName, everything goes right. If I try to use asource...
0
by: AntonB | last post by:
I am using Visual Studio 2005 Beta1 and get the following errors when building a .NET class library (called TryDLLPr in the example below). Any advice on what's wrong will be greatly appreciated. ...
4
by: Jeff | last post by:
We have multiple ASP.Net web apps in development. As a standard we are looking to go with SQL Server to hold state information. Can we have the multiple apps all point to a single State DB? Or...
9
by: viz | last post by:
hi, i have written a class for session handling, and i want to use it to keep track of the user. After authenticating the user in login page i am storing the session info like uname etc.. in a...
6
by: Ryan Liu | last post by:
Hi, If I have tens of thousands DataRow in a DataTable and allow the end user to pick any DataColumn(s) to check for duplicated lines, the data is so large, is there a better API, algorithm can...
6
by: Bob Weiner | last post by:
I have a few dll's that return their own version of Account objects. In the asp code I am writing now I would like to define an interface, called IAccount, and convert each of these objects (...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.