MVC 2 - Are Sattelite assemblies required for embedded resources? Embedded resources not working - asp.net-mvc-2

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.

Related

Are there any alternatives to T4 templates and EnvDTE for cross platform asp.net 5 development?

We currently use T4 templates to generate C# code files based on C# Code (Entity POCO's) and the EDMX (in older applications)
Moving to ASP.NET 5 with a view to support cross platform development, are there any code generation tools available that can read a projects class & meta data structures, and to generate C# files at design time, similar to T4 templates?
You can try Scripty - it is Roslyn based scripting.
Syntax highlighting for *.csx files works out of the box;
VS extension exists to process scripts on save;
MSBuild task exists to process scripts during buld process;
Script allows you to traverse a hierarchical model of the project;
Multiple files generation from single script is supported;
yeoman seems to be a good option. There exist some generators already for scaffolding asp.net 5 apps and you can create your own generators
It is cross platform and can be used on linux/mac/windows.
Even tt templates weren't supported earlier in asp.net-5 projects. It has been added recently (in Visual Studio 2015 Update 1).
The discussion is here: https://github.com/aspnet/Home/issues/272
And in the thread, Eilon said the Roslyn is the way to analyse the code and generate new ones... And he again said the ASP team has no immediate plan. So currently we have no solution from Microsoft.
But I did some search and didn't find any cross platform community tool to generate codes based on other codes. :(
Scriban worked for me as an alternative to replace T4 templates for generating unit test code. But it's a pure templating engine.
The new LeMP preprocessing engine for C# can be used as an alternative to T4 templates. May I ask what specifically you mean by "projects class & meta data structures"?
For this purpose I created a simple python
script called "autogen".
How it works: the script takes jinja template file (instead of T4) and data file (json) and generates one or multiple output files (e.g. C#, or any format) based on the template.
How it can be used (example): describe interface (methods, parameters) definition in json file, create *.j2 template files for C#, Java, Python, etc.. Then run autogen.py script and files for proxy/stub for all languages will be created.
This can help to create lot of similar code without copy/pasting and make code changes by simply changing single json file.
Moreover it can be integrated with build pipiline, msbuild (.net, .net core) and is cross-platform.
I have been looking into this same sort of thing, although not specifically with ASP.NET MVC but across project types as I move to .Net Core. I kept my T4 relying on EDMX early on. Which works out since EF7 moves beyond the file format in favor of code. Where I was planning on going with my code generation was a combination of ScriptCS and C# REPL. Roslyn complicates things for me a tad since there are no design time assemblies from what I understand. So the trick may be to understand and introspect cs files from within the project.

Using OnMethodBoundaryAspect across multiple projects

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.

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).

Multiplatform MSBuild project file

I'm currently working on a project which source code should be as portable as possible; that is, the project (in C#, but it is not very relevant) represent an application that should be executed on Android (with Mono-Android), on iPhone (with MonoTouch) and WinMobile (with official Compact Framework). Without going into details, the corresponding MSBuild solution consists of an independent-platform library (from a source code point of view, at least) which declare various interfaces and classes that represent an abstraction of each feature that is not common to the various platform (i.e. the UI). In addition, there are a corresponding library that specialize (for each platform) the "base library"; the effective application executable is a program that uses the abstraction and the common standard libraries.
Developing on WinMobile and Android is not really a problem: Mono-Android add-in can be installed on VS 2010, so both platforms can be handled with MS VS.
Initially the solution was created in VS, so the initial configuration and the related projects (Android and WinMobile) are automatically generated.
After that I've imported the solution in MonoDevelop under Mac (the only platform that is officially supported by MonoTouch), and I've created the project for the iPhone library; switching the configuration to generate the assemblies (iPhoneSimulator) the "base library" was not possible to compile due to a missing project type configuration; specifically, the GUID used by MonoTouch for <ProjectTypeGuids> is {E613F3A2-FE9C-494F-B74E-F63BCB86FEA6}; adding this GUID I can now compile "base library" in MonoDevelop.
The problem arises when I try to re-import the solution in VS: since there's no Windows version of MonoTouch, VS cannot find the add-in for the specified project type, and the project doesn't load.
Looking to the specifications of MSBuild project file, it seems that there are tons of options that cannot be set or modified within the project/solution editor in VS; however the format is quite complicated and now I'm asking your help!
Is there a way to specify in the project file that a project type is present only if a particular configuration is selected independently to which is the environment I'm using?
The general approach is something like this; a condition that progressivly builds your property, referencing any value the property already may have:
<ProjectTypeGuids
Condition="'$(BuildingInsideVisualStudio)' != 'true'"
>;{E613F3A2-FE9C-494F-B74E-F63BCB86FEA6}"</ProjectTypeGuids>
<ProjectTypeGuids>{OTHER-GUIDS-HERE}$(ProjectTypeGuids)</ProjectTypeGuids>
This will detect the VS condition (when building) and omit the unkonwn guid. I'm not sure however if it will work when the project is opened, this property might only apply to building. There may be a similar "sentinal" property for building on Mono, and you can reverse the condition.
I solved an unrelated, but very similar issue of cross-platform development by excluding the files that presented themselves as cranky when going between Linux and Windows. I have my project under source control and utilized that to keep things working cooperatively.
http://www.aydabtudev.com/2011/05/what-goes-into-source-control-android.html
It's not a 1-to-1 for your issue, but it might give you clues/ideas on how to solve your problem.

How to Deploy Resource to Hive in Sharepoint 2010

I've read a lot of examples and tutorials about it. But none of the so called solutions helped me in my case.
Problem:
I have multiple web parts using the same resource files, so there is a solution for resource files that has a mapped folder to Resources with resx files in it.
When I deploy with resx file's "build action" property set to embedded or none, resources are not deployed to Hive/Resources.
When I deploy with "build action" set to "content", resources are deployed but the webparts that use resources get the error below:
Could not find any resources
appropriate for the specified culture
or the neutral culture. Make sure
"ResourceWp.Resources.ListNames.resources"
was correctly embedded or linked into
assembly "ResourceWp" at compile time,
or that all the satellite assemblies
required are loadable and fully
signed.
This is the place where my last healthy nerves couldn't resist the pain. I want to use the resx file neutral in culture like any simple asp.net webApp. I think something really simple is here that I'm missing because of my lack of knowledge about the assembly usage.
Through all the reading, I just couldn't understand one point that if I am able to use resource files like super.resx without writing super.en-US.resx (neutral I mean).
Because only difference that I have is this point, I don't use any tr-TR or likewise culture identifier and I use this project in a Turkish language-pack installed and in a site created by selecting "Turkish" as language.
But in my opinion, that shouldn't be the point, right?
Summary:
I want to deploy my resource in Hive/Resources and them to be available to my webparts
I have tried:
http://johanleino.wordpress.com/2010/11/08/working-with-resource-files-in-sharepoint-2010/
http://weblogs.asp.net/jevgeni/archive/2010/02/02/using-resource-files-in-sharepoint-2010-and-visual-studio-2010.aspx
kind of approaches. But didn't accomplish any success with them.
I hope, someone can help me, thanks in advance.
It seems as it is necessary to place the resource files in App_GlobalResources folder. This approach worked well in my (similar) case: https://sharepoint.stackexchange.com/questions/20851/localizing-asp-markup-in-webpart-issue