I have added a resource file in App_GlobalResources called FileList.resx.
Now I access the contents within the code by using
My.Resources.FileList.astro1 etc.
It works fine if I set the Build Action of resource file to Embedded. However in this case the resource file is not available after compile and I can't change it later.
If I set the Build Action to Content I get an error : Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "WAP.FileList.resources" was correctly embedded or linked into assembly "WAP" at compile time, or that all the satellite assemblies required are loadable and fully signed.
Please advice me.
Are you using a Visual Studio Web Application? Or a Web Site?
In the latter case, you should be able to change the Resource file after deploying the site, and it should get automatically recompiled on the server. In the former case, it's a built-in that can't be changed after the site is compiled before deployment.
If that's a problem for you, there are of course alternatives to Resource files....
In any way of compiling and deploying your application all resource files will compiled in related to each resource file assemblies. In all cases, resource assemblies are ultimately created for each directory in the site, and satellite assemblies are generated beneath their respective culture-specific directories. Even when the site is JIT-compiled, the outcome is equivalent.
So, you must use Build Action of resource file to Embedded, but as possible solution for dynamic resource definition you can place you resources in a database. And even provide a Resource provider. In that case your database solution would have all the benefits that suggested by resource management aka dynamic culture definition, using resource binding to control, etc.
Here you can find some tutorials how to implement Resource-Provider Model in your application:
Extending the ASP.NET 2.0 Resource-Provider Model
Creating a Data Driven ASP.NET Localization
Resource Provider and Editor
Related
I have a web application that contains a bunch of classes in the App_Code folder. I compile the project and publish it to the IIS server.
I want to share some of the code in the app_code folder with another application on the server and therefore I think I need to register an assembly in the GAC.
What is the best way to do this? I have read this article: http://msdn.microsoft.com/en-us/library/Aa479044, which suggests a number of options?
Put the code in a class library, and add the library as a project reference to both applications.
Side Note:
If you need to access the request or response, etc. import the Sysyem.Web library and use the HttpContext object. This will give you most, if not all the information available to the page.
You'll have to move the code into a separate project, which will output a library.
If you have any references to dlls related to the ASP .Net or web in general, you can reference them from that library.
The code might not compile in the first, but you can refactor it, it really depends on how tight is with what is in App_Code.
You can then reference that library on the Web Site (you'll have to refactor here too some things). The library, once is signed, can be added to GAC also.
The solution for me was to expose the shared functionality in a web service.
I have encountered a very strange issue with localization in ASP.NET MVC. Let me outline my projects since it is not that straight forward.
I have a TRUNK version of my website. The website uses two localization techniques. The first one is to load resources within the views from App_LocalResources. The second technique is to load resources from embedded resources in DLLs (project references).
On one view I show some lables which are localized from the view and I also load some labels via AJAX/JSON. The Action gets the localized data from an embedded resource in a referenced class project (DLL). Actually, in TRUNK, this works pretty well.
Now the Problem: I have a BRANCH which does not have a project reference to the embedded resource but a reference to a compiled DLL (copy). In the BRANCH the localization only works for the View, not for the AJAX/JSON call which simply returns the default locale.
What can be wrong? Do you have to make an settings on the DLLs if you redistribute them?!
Q:
Recently , i face some problems, i have a dll common among a lot of applications,and any change to this dll require to build it, copy and paste it in each bin folder of these applications ,and add the new reference so i decided to convert this dll to a web service in stead to overcome this overload..
I make a web service application contains set of web services(mapping to each class).
I face some problems here:
In the original dll, there are
classes use methods exist in other
classes in the same dll, and i face problems when i
tried to use web service methods in
other web service class.how to fix
this problem.
In the original dll there are set of
static classes with static
methods.how to make the equivalent in
my web service application.
Any overload method cause a problem
in my web service.
When using Dictionary<string, string>
as a parameter in my method.
Note:the original dll contains the connections to the data base. Is converting it to web service is the optimum solution?which one is faster in my case a web service or the dll?Should i tend to WCF instead of?
thanks in advance.
In my applications I usually have all related projects in the same solution. But when I need to use projects across applications I replace the project for a dll reference.
Because I use Subversion I solve the problem of copying the dll by adding an external property do my libs folder, referencing the build of the dll.
If the external dll is updated very often than you probably need a continuous integration system to handle that for you.
I usually add project reference and keep all my projects under single solution, so I do not have file copy issue. You might be missing project reference, instead you could have used assembly reference. Verify that first.
First advice, don't create a web service if you don't know what it is and how it can be used. People tend to think everything is a web service since creating a web service in WCF is so easy by using visual studio tools. Since you ask like converting DLL to a web service, I assume that you are beginning with learning web service.
All you need is kind of continues integration system otherwise a simple build system which does the build for you and it copies the files wherever depended applications folder. Hence you can save your time for coping files manually. When you do this, you will not have any of those 4 problems you have mentioned.
If you are lazy enough to learn the build system, simply write a batch file that would copy the files for you. I do have batch files which does xcopy files.
A couple of questions:
Is App_WebReferences for WCF schema files? Should this not be App_ServiceReferences?
Also, what is dynamic compilation in ASP.NET?
Thanks
From MSDN:
App_WebReferences folder Contains
files used to create a reference to a
Web service (in the same project or
external to the project), including
.disco and .wsdl files
There's no special folder in ASP.NET called App_ServiceReferences.
As far as dynamic compilation is concerned you may take a look at this article which explains it very good.
I have a web app that I wanted copy to a new project.
I created the new app with VS2003 and copied across the web forms, config, global asa, etc. and made sure IIS says it is a web app.
However, I still get this error when I run the app using IE from VS IDE:
ASP.NET v1.1 Could not load type TBRWEB.frmLogin
I also made sure the assembly name and root namespace are the same as original.
Any ideas?
These error normally occurs if the .aspx page or the Global.asax page contains a reference to a code-behind module and if the application has not been built.
Look in your project settings and check the value of the default namespace (in the application section).
Then check the "inherits" attribute in the control header of your ascx control (and yll other aspx/ascx files). I suspect that these two names are not the same. Creating a new project maybe you choose a different name which became the default namespace.
The simplest solution would be to change the namespace of your project to TBRWEB, if that is an option.
if it is not that easy, then my follow-up questions are:
Did you successfully build (compile) the application?
If it's a ASP.NET web site (not web project), did you forget to copy the .cs/.vb files in the App_Code folder?