Using OnMethodBoundaryAspect across multiple projects - postsharp

I am having a problem with OnMethodBoundaryAspect used by different projects. In particular I have
- root website which is MVC
- sub-website in ASP.NET
- business & data access layers called both by MVC and ASP.NET
I have implemented my own tracing class VerboseTracing : OnMethodBoundaryAspect, within a separate stand-alone logging DLL.
I have added the attribute at the assembly level in both MVC and ASP.NET project
What I am seeing is that the tracing is only outputting for methods in the MVC project. All the projects reference the logging DLL, as indicated in Using PostSharp OnExceptionAspect across mulit projects.
Any help would be appreciated as I REALLY REALLY need the logging to work in the non-MVC projects.
I am attaching the VerboseTracing class.
Thanks

Checkout the AttributeTargetAssemblies attribute parameter.
Here is how I have been able to use aspects across multiple projects. The only difference being I am using a project rather than direct assembly reference to the aspect code.
I add the below line, (with proper assembly and namespace) for every other assembly\namespace I need to add aspects to, that my web project code uses.
[assembly: ProfileAspect(AttributeTargetAssemblies =
"BusinessLogic.Assembly.Name", AttributeTargetTypes =
"BusinessLogic.Assembly.Namspeace.*")]

I think AlexD might be on to something. You should include your logging DLL, and any dependencies the logging project requires to run inside of your ASP.NET project. So I would assume the logging project depends on PostSharp, so PostSharp should also be installed to the ASP.NET project.

Related

Is there a way to create just ONE NuGet package that will target multiple project types (web forms, MVC, etc.)?

My company commonly uses Web Forms projects and MVC projects within Visual Studio. When creating a package, the package will/should be different for the different project types.
QUESTION: Rather than creating two slightly different NuGet packages that do exactly the same thing for the two different project types, is there a way to just create ONE NuGet package that's project-type independent? So when installing the package, there will be logic in, perhaps, the .nuspec file that will say "if the project this is being installed on is Web Forms, then do this. If it's MVC, then do this".
I've looked at the following link, for the different ProjectProperties on a project - this seems like something I would utilize, but I'm not sure how.
I would not create a single package for different platforms, because you're loosing flexibility. You might want to take a look at how the Glimpse guys have created their packages as they were facing the same issue.
Check the following packages and the way they are chained:
http://www.nuget.org/packages/Glimpse/
http://www.nuget.org/packages/Glimpse.Mvc4/
http://www.nuget.org/packages/Glimpse.AspNet/

What does the Hammock.dll do?

I referenced the Couchbase assembly using NuGET in my project and it has a dependency on Hammock.dll. What does this assembly do? And is it really needed? In simple unit tests, my application works fine without the Hammock.dll being present. But I don't want any surprises when I move this app to production.
I would say [couchbase] still needs it, given there is a HammockHttpclient.
To answer the original question:
Hammock is an HTTP API library for .NET that greatly simplifies consuming and wrapping RESTful services.
This can easily be reasearched by going to the CouchbaseNetClient page and under Dependancies clicking Hammock. You can also go to the Couchbase Project and browse through the source to view if/where the library is still being used (as I have linked in the first sentence).

MVC 2 - Are Sattelite assemblies required for embedded resources? Embedded resources not working

Hello I have been working on an MVC 2.0 web application.
This has the requirement to switch between 2 languages.
The existing solution did not work well as the MVC [DisplayName] attributes and data annotation error messages etc did not work as they were not culture aware in MVC 2.0.
I followed the example here:
http://adamyan.blogspot.co.uk/2010/02/aspnet-mvc-2-localization-complete.html#!/2010/02/aspnet-mvc-2-localization-complete.html
With a few tweaks it is all working perfectly in my Visual studio Environment and switches language and uses the MVC diplay name etc fine now.
I am using embedded resources and have an English resx file (e.g MyPage.resx) and the culture version (e.g. MyPage.cy-GB.resx).
The problem is when I install this into a production environment it is not switching languages.
I am baffled since I thought these embedded resources would be part of the main web application dll so it should have no trouble finding the matching resource?
I know it is definitely changing the culture on the current thread. It just isn't loading the matching resource.
The application is installed using WIX without harvesting but I have included all files (aspx etc). Previously it was using a satellite assembly and creating a resource dll in the bin folder with the culture name. I removed this as I am just using embedded resources as mentioned. Is the satellite assembly a requirement for this? I am quite happy for them to be embedded.
I am really confused about how to resolve this so any advice would be very welcome.
Thanks
The MyPage.cy-GB.resx is embedded in the satellite assembly. It is necessary, in fact embedded resources are all that goes into satellite assemblies.

How to use mergelocales.py for GWT across Multiple Projects

I have some projects:
WebShared (Java Library project)
WebExternal (GWT Web Application)
WebInternal (GWT Web Application)
I have UI Binder's which are shared between WebExternal and WebInternal, and I organize those under the "WebShared" project.
I am now adding i18n support, and I want to use UI Binder's <ui:msg> tags, and consolidate them using the GWT-P mergelocales.py script.
Mergelocales.py works by running against a GWT app that was GWT compiled using the -extra parameter. Since WebShared is not a GWT app, running the script against it produces no output. Additionally, running mergelocales.py against WebExternal or WebInternal does not produce a file that includes the messages from the WebShared project.
I believe it would work if I converted the WebShared project into a GWT project, but then I would still have two separate properties files to send to the translation service, and I don't want to deal with combining files or managing multiple files.
What is the best way to handle this scenario using the available tools, OR do I need to create my own script?
Thanks in advance for the help.
Solved.
This actually works by default. When the GWT Compiler runs, it generates .property files for the UI Binders that are localized, even if used from a dependent project, and the mergelocales.py script runs against those property files.

ActiveReports Upgrade Error

I just upgraded from ActiveReports 2.0 to 3.0. All rpx files have been converted to *.vb files. The ActiveReports project has this class hierarchy:
*.vb with designer -> PrintBase.vb -> ActiveReport3
When I opened any of the *.vb files, I got this error:
The designer could not be shown for this file because none of the classes within it can be designed. The designer inspected the following classes in the file: xxx --- The base class 'PrintBase' could not be loaded. Ensure the assembly has been referenced and that all projects have been built.
Call stack:
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.EnsureDocument(IDesignerSerializationManager manager)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at System.ComponentModel.Design.Serialization.BasicDesignerLoader.BeginLoad(IDesignerLoaderHost host)
Then I went through PrintBase.vb. There was no compile error. Then I modified one of the *.vb files to this:
Hello.vb -> ActiveReport3
The designer worked without any problems. The PrintBase has quite a bit of code. To simplify the debugging, I created a new .vb file called BasePrint that inherits from ActiveReport3. So, the hierarchy is back to:
Hello.vb -> BasePrint -> ActiveReport3
Then I saw the same error above again. It seems like AR3 designer does not allow .vb files to inherit from a base class according to my debugging. But I am not quite sure. BTW, the ActiveReports project is vb.net. There are other C# projects under a VS 2008 project solution. Is the mixing of VB.NET projects and C# have anything to do the miagration / upgrade process?
Thanks.
Indeed, the class-style inheritance was not supported by the upgrade utility in the ActiveReports 3.x designer. However, after an upgrade is complete you should be able to put the base class bad (the way that you described) and the designer should safely ignore it. If you're still having problems try to close the project, do a clean (delete the old assemblies that might be referncing the old PrintBase class) & close visual studio and reopen it again to get a fresh start.
You can find more information about upgrading reports from ActiveReports 2.x to ActiveReports 3.x at the following page: link text
However, it seems you are using inheritince in this case to share some utility methods and maybe some state (e.g. in class-level fields maybe). For this it is best if you have your reports inherit directly from ActiveReport3 and use "BasePrint" as a sort of utility class that your reports call functions in. Normally this has no disadvantage other than having to prefix the method calls with the name of the corresponding BasePrint instance/variable name and it simplifies dealing with ActiveReports designer in the scenario you describe.
However, ActiveReports does support a visual inheritence that allows a base report to share controls with a derived report. There is more information on how to use this feature at the following location: http://www.datadynamics.com/Help/ARNET3/ar3tskInheritance.html. However, I want to stress that this is a different style of inherience than you are using so it may not be applicable to what you need.
Also, you should try to convert again without having a combined solution with C# and VB projects. I don't know that this is a problem but it is certainly not the most common way the converter is used and may be complicating things.
Finally, you should be aware that ActiveReports 6 is now available and you may want to consider trying out that version.
If you continue to have any problems please contact our support team at support#grapecity.us.com or use our public forms that have many ActiveReports experts monitoring them every day at the following links:
http://www.datadynamics.com/forums/73/ShowForum.aspx - ActiveReports 3 Forum
http://www.datadynamics.com/forums/82/ShowForum.aspx - ActiveReports 6 Forum
Scott Willeke
GrapeCity / Data Dynamics