473,722 Members | 2,397 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

InternalsVisibl eTo for Web Project

I have an assembly with some internal methods that I have to access from my
web service. I learned that I can use “InternalsVis ibleTo” to enable such
access. Since I have control over both the class library project (with the
internal stuff) and the web project it seems that the scenario is possible.
However, the problem seems to be with the web service project being a web
project.
I followed all possible documentation and postings to create, sign and make
assemblies friendly. If I try to consume my class library (with internal
types) from a windows application (which was made trusted) everything works
perfectly as expected. If, however, I try to use it from within my web
project I get errors that the internal types and methods from the class
library are not visible:

Error 12 'EPHandl.Vault. PaymentVault' is inaccessible due to its protection
level c:\inetpub\wwwr oot\epService\A pp_Code\CCProce ssor.asmx.cs 111 13 http://localhost/epService/
Error 13 'EPHandl.Vault. PaymentVault' does not contain a definition for
'GetCreditCard' c:\inetpub\wwwr oot\epService\A pp_Code\CCProce ssor.asmx.cs 111 26 http://localhost/epService/

Here is how I indicated that I trusted the web project from the class
library project:
[assembly: InternalsVisibl eTo("App_Code,
PublicKey=00240 000048000009400 000006020000002 400005253413100 04000001000100d d31afb809fb4cda a134816a2dbadca 223b0df0fffe8cf 82842b5b848c2d5 1fb71a7f5b71273 328d26d48faa835 1e905105a5cb9b5 103c442cbc20765 e8404225b0ffac9 8dfe04de6536d5c cad16d3bb05791e 9be1c8fedc65d3e 77253aedff6f21d 6d69dfb6cad9ffc 4c4be8e752951ed 6fd126f8c4df8c5 6457b2c38163ec4 ")]
I understand that the way web project is implemented in VS2005, it is not
fully compiled and signed until later point, so how can the
InternalsVisibl eTo attribute be used to point to web projects’ assemblies?
There has got to be a way.

Thanks.

--
http://www.zbitinc.com
Mar 22 '06 #1
9 2894
Hi Gzinger,

Welcome to the ASPNET newsgroup.

As for the InternalsVisibl eTo attribute, it requres us to provide the
assembly's filename or optionally the strong-name token to idenitity the
assembly we allow to access internal class or type. However, for ASP.NET
2.0, it adopts the new dynamic compilation model, the assemblies' name is
randomly generated, it'll be hard for us to provide a fixed name for them.
Yes, there does exists some helper project or add-on can help do the
precompilation and make the pages or App_Code classes be compiled into
fixed name assemblies, however, we're still not recommended to use the
InternalVisible To attribute with such mangled assembly name. IMO, you can
consider creating a separate class library project and put the code which
need to access the target assembly's internal data there. And in the target
assembly, you add the "InternalsVisib leTo" attribute against this class
library assembly. Thus, we can use this class library in our ASP.NET web
application. How do you think of this?

Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may

learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 23 '06 #2
Dear Steven Cheng,

Thank you for your response. I already thought about the approach that you
suggested where an intermediate library that is trusted by the “internal
code” basically wraps it up exposing those internal types and methods to the
outside world. Besides that approach being not very elegant, my main concern
is that once we open that back door we can not control who is going to
enter/exit trough it, which essentially defeats the purpose of the whole
architecture. I understand that I would have to go with this approach if you
are saying that there is no the proper way, but I am very reluctant to do
this. I just want to make sure that I understand you correctly – are you
really saying that InternalsVisibl eTo paradigm does not apply to web project
assemblies?
I also would like to get more information on the other approach that you
mentioned – namely “helper project or add-on can help do the precompilation
and make the pages or App_Code classes be compiled into fixed name
assemblies”. I understand that you do not recommend this approach but I still
would like to know what are the challenges and tradeoffs. Could you please
elaborate on the subject a bit more? Perhaps point out the exact tools I can
use?

--
http://www.zbitinc.com
"Steven Cheng[MSFT]" wrote:
Hi Gzinger,

Welcome to the ASPNET newsgroup.

As for the InternalsVisibl eTo attribute, it requres us to provide the
assembly's filename or optionally the strong-name token to idenitity the
assembly we allow to access internal class or type. However, for ASP.NET
2.0, it adopts the new dynamic compilation model, the assemblies' name is
randomly generated, it'll be hard for us to provide a fixed name for them.
Yes, there does exists some helper project or add-on can help do the
precompilation and make the pages or App_Code classes be compiled into
fixed name assemblies, however, we're still not recommended to use the
InternalVisible To attribute with such mangled assembly name. IMO, you can
consider creating a separate class library project and put the code which
need to access the target assembly's internal data there. And in the target
assembly, you add the "InternalsVisib leTo" attribute against this class
library assembly. Thus, we can use this class library in our ASP.NET web
application. How do you think of this?

Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may

learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 23 '06 #3
Thank you for the response Gzinger,

Yes, I can understanding your concern on this. Using an additional class
library may not be quite elegant. As for the ASP.NET 2.0, we can produce
precompilation on the website, you can see the precompile options when
select the "Build-->Publish WebSite" menu. Also, ASP.NET team provide a new
"web deployment project" which can help us do more customization on the
precompiled assembly of the web project:
#Visual Studio 2005 Web Deployment Projects (Beta V2 Preview)
http://msdn.microsoft.com/asp.net/re...p/default.aspx

For example, it can help the pages or components in different folder be
compiled into separate assemblies and the assembly name can adopt a fixed
naming rule.

However, I'm not quite sure whether there is any problem if we use
"InternalsVisib leTo" attribute against such precompiled assembly. If you
do not feel very very urgent, I will discuss this issue with some other
ASP.NET experts to confirm this. I'll update you as soon as I got any
update.

Thanks for your understanding.

Regards,
Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may

learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 24 '06 #4
Dear Steven Cheng,

Yes, please find out more information on the other options from your ASP.NET
experts and please let me know.

Thanks.

--
http://www.zbitinc.com
"Steven Cheng[MSFT]" wrote:
Thank you for the response Gzinger,

Yes, I can understanding your concern on this. Using an additional class
library may not be quite elegant. As for the ASP.NET 2.0, we can produce
precompilation on the website, you can see the precompile options when
select the "Build-->Publish WebSite" menu. Also, ASP.NET team provide a new
"web deployment project" which can help us do more customization on the
precompiled assembly of the web project:
#Visual Studio 2005 Web Deployment Projects (Beta V2 Preview)
http://msdn.microsoft.com/asp.net/re...p/default.aspx

For example, it can help the pages or components in different folder be
compiled into separate assemblies and the assembly name can adopt a fixed
naming rule.

However, I'm not quite sure whether there is any problem if we use
"InternalsVisib leTo" attribute against such precompiled assembly. If you
do not feel very very urgent, I will discuss this issue with some other
ASP.NET experts to confirm this. I'll update you as soon as I got any
update.

Thanks for your understanding.

Regards,
Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may

learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 24 '06 #5
Sure, Ill update you as soon as I get any further info.

Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may

learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.
Mar 24 '06 #6
Hi Gzinger,

I've just got some further feedback from other dev and consultant guys and
it seems that so far there is no other better means and they also recommend
use a separate class library to do this. Here is the original description
from them:

=============== =============== ====
in my opinion no assembly should have any references to a Web Site
assembly, because this strongly implies a flaw in your overall
architecture. In layered architectures, no layer should have any dependency
on another layer higher on the stack. InternalsVisibl eToAttribute doesnt
violate this by itself, but it opens the door for all kinds of undesirable
dependences. A Web Site is also a very awkward vehicle to promote reuse.
Reusable stuff in the web UI layer is better kept in a regular class
library.

My 2 cents
=============== =============== =====

Thanks for your understanding.

Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 28 '06 #7
Thanks. I am alredy doing what is suggested.

The only other thing on which I disagree with your collegue is that
InternalsVisibl eTo is not a useful paradim for the web projects (even if
there was a way to utilize it, that is). Please remember that the sole
purpose of a web project COULD BE to host web services. In such case if one
would like to separate out business logic, but putting it in a distinct class
library, InternalsVisibl eTo would come very handy.

Thanks.
--
http://www.zbitinc.com
"Steven Cheng[MSFT]" wrote:
Hi Gzinger,

I've just got some further feedback from other dev and consultant guys and
it seems that so far there is no other better means and they also recommend
use a separate class library to do this. Here is the original description
from them:

=============== =============== ====
in my opinion no assembly should have any references to a Web Site
assembly, because this strongly implies a flaw in your overall
architecture. In layered architectures, no layer should have any dependency
on another layer higher on the stack. InternalsVisibl eToAttribute doesn¡¯t
violate this by itself, but it opens the door for all kinds of undesirable
dependences. A Web Site is also a very awkward vehicle to promote reuse.
Reusable stuff in the web UI layer is better kept in a regular class
library.

My 2 cents
=============== =============== =====

Thanks for your understanding.

Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 29 '06 #8
Thanks for your followup Gzinger,

Yes, you're right that when the ASP.NET application used to host webservice
it will a bit painful to have this problem. So currently I do admit that
this is an exist problem due to the dynamic compilation model. You can also
submit this on the MSDN product feedback center :

http://lab.msdn.microsoft.com/produc...k/default.aspx

Thanks for your understanding.

Regards,

Steven Cheng
Microsoft Online Community Support
=============== =============== =============== =====

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

=============== =============== =============== =====
This posting is provided "AS IS" with no warranties, and confers no rights.

Mar 29 '06 #9
Thus wrote gzinger,
Thanks. I am alredy doing what is suggested.

The only other thing on which I disagree with your collegue is that
InternalsVisibl eTo is not a useful paradim for the web projects (even
if there was a way to utilize it, that is). Please remember that the
sole purpose of a web project COULD BE to host web services. In such
case if one would like to separate out business logic, but putting it
in a distinct class library, InternalsVisibl eTo would come very handy.


Why? It's exactly the same story... you might introduce a dependency from
your business logic to some technical infrastructure, i.e. the web services
assembly. And once that has happened, the two are tightly coupled.

Cheers,
--
Joerg Jooss
ne********@joer gjooss.de
Mar 29 '06 #10

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

Similar topics

0
1551
by: public heath vb developer | last post by:
We have a solution with 29 projects including a main menu and 28 dlls. One of the projects (Project B) was created by copying an existing project (Project A), making changes including the assembly name, root namespace, form name, and internal code. When the new project (Project B) was added to the solution and a reference to it was attempted to be added to the main menu project (Project MainMenu), the new project (Project B) reference did not...
5
11050
by: David Webb | last post by:
The problem started when the Working Folder for a project was somehow set to the folder of another project. I set the correct working folder in VSS and deleted the .vbproj files that had been created in the wrong folder on the hard drive. Before I discovered these files, .NET kept trying to create a new project with _1 following the project name. Deleting those files corrected that problem. I deleted the Virtual Directory, rebooted, and...
0
1490
by: Patty O'Dors | last post by:
Hi I am experiencing the following issue when building an ATL component that is tested with c#: The ATL project builds first, then the C# project, as the ATL DLL is a dependency of the C# project. The C# project has got a control from the ATL DLL on one of its forms, and as such, whenever VS is loaded with the C# project, it has got the DLL loaded into its process space until it is shut down. Hence, it is impossible to build the ATL DLL...
2
2421
by: Vish | last post by:
Hi all, I have a VS.NET (2005 BETA2) solution that has five winforms projects. Here are the details. Project-A (Main, startup project), references Project-B (class lib project) Project-B (Class lib project), references Project-C (Class lib project) Project-C (Class lib project), references Project-D (Class lib project) The problem i am having is Project-D.dll is in the (bin) folder of Project-C but not in Project-B's bin
2
4784
by: Rudy Ray Moore | last post by:
How can I modify the project build order of a multi-project workspace under "Visual Studio .net 2003 7.1 c++"? I tried to modify the .sln by hand to influence the build order, but it didn't seem to help. It looks like it's in reverse alphabetical order with upper case characters winning. Contents from my "Output" window: Build started: Project: Utility Build started: Project: USMTF Build started: Project: Tracking
4
2888
by: Brad | last post by:
I'm not one to rant or flame....so please excuse me while I do so for this once. I've now spent a bit of time working with VS2005 beta 2 to see how it functions for web development, especially how our current extensive number of .Net 1.1 web apps convert to it. After a week's time I dont's mind the converted app code that was broken and had to be changed, due to deprecation, new framework classes (some of which have names identical to...
0
1428
by: Andy | last post by:
Hi all, I'm trying to create unit tests in a seperate assembly from the library. However there are some internal classes that deserve testing but are not intended to be used by the public. I'm trying to use the InternalsVisibleTo attribute so that the unit test assembly can see the internals of the library for testing. The unit testing is done a release version which is given a strong name (the unit test assembly gets a strong name...
4
8751
by: Mike | last post by:
Hi. I've strong-named an application using the 'Signing' option in project properties. Four friend assemblies exist in AssemblyInfo.cs, and look like this: After strong-naming the application my friend references are giving the error: "Friend assembly reference Microsoft.Practices.EnterpriseLibrary.Logging.Tests is invalid. Strong-name signed assemblies must specify a public key in their InternalsVisibleTo
29
2820
by: Tony Girgenti | last post by:
Hello. I'm developing and testing a web application using VS.NET 2003, VB, .NET Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1 on a WIN XP Pro, SP2 computer. I'm using a web form. How do I move this project/solution from a local development xp pro computer which uses IIS/localhost, to another xp pro computer that is on a Windows 2003 server domain. I want to be able to use the Windows 2003 server IIS instead of localhost.
0
8863
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8739
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9384
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9238
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6681
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4502
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3207
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2147
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.