.resx not working with vb code - asp.net

I am making an asp.net web application with vb coding behind. I found a code online for making a multilingual website, and as the original code is in C# I made a C# project to try it. Everything went fine. Now, I converted the code to VB to use it on the original project, and for some reason, the Debugging doesn't want to start, always throwing MissingManifestResourceException as an error. The resource files' Build Action is set to Embedded Resource, and the Code I am using is this:
Dim rm As ResourceManager
Dim ci As CultureInfo
Private Sub LoadString()
Thread.CurrentThread.CurrentCulture = New CultureInfo(Session("Lang").ToString())
rm = New ResourceManager("WebApplication6.App_GlobalResources.Lang", Assembly.GetExecutingAssembly())
ci = Thread.CurrentThread.CurrentCulture
NavigationMenu.Items(0).Text = rm.GetString("MenuItemDefault", ci)
NavigationMenu.Items(1).Text = rm.GetString("MenuItemAbout", ci)
End Sub
Where "Lang" is the name of the base Resource File. The files' name:
Lang.en-US.resx, Lang.es-ES.resx
The whole error looks like this:
MissingManifestResourceException was unhandled by user code
Could not find any resources appropriate for the
specified culture or the neutral culture. Make sure
"WebApplication6.App_GlobalResources.Lang.resources" was correctly embedded or linked into
assembly "WebApplication6" at compile time, or that all the satellite
assemblies required are loadable and fully signed."
Again, in C# the whole thing worked. This code is Placed in a function, which is called from the Load_Page form.
Thanks in advance for your help!

After spending hours trying to figure out, I found a solution.
What I did was replace this string:
rm = New ResourceManager("WebApplication6.App_GlobalResources.Lang", Assembly.GetExecutingAssembly())
With this one:
rm = New ResourceManager("WebApplication6.Lang", System.Reflection.Assembly.Load("WebApplication6"))
But removing "App_GlobalResources" from the original string also worked. So the other posible solution is:
rm = New ResourceManager("WebApplication6.Language", Assembly.GetExecutingAssembly())
After replacing the string I just left everything else as it is in the main post. Now everything's working fine.

Related

How to use ReportingCloud in asp.net web site?

Recently I have started to work with SSRS and found ReportingCloud. It says
ReportingCloud provides an open source quality implementation
as an extension of the RDL specification
I haven't found any tutorial/documentation on how to use it in sourceforge or via google search.
Can anyone give an walk-through/example on How to use ReportingCloud?
There is one partial example available at http://sourceforge.net/projects/reportingcloud/forums/forum/1116661/topic/4571059.
The example takes an existing RDL file, parses and executes it and then places the HTML output into an asp.net Literal Control for display in the browser.
That code snippet is repeated here:
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("C:\MyFolder\MyReport.rdl");
RDLParser rdlp = new RDLParser(xmlDoc.OuterXml);
rdlp.Parse();
MemoryStreamGen ms = new MemoryStreamGen();
ProcessReport pr = new ProcessReport(rdlp.Report, ms);
pr.Run(null, OutputPresentationType.ASPHTML);
// Dump memory stream (HTML Text) to an out-of-box ASPX Literal control
this.LiteralReportHtml.Text = ms.GetText();
To do this you'll need a reference to ReportingCloud.Engine.
I'm not sure exactly what your bigger goals are but I'd like to draw your attention to another open source project on GitHub called My-FyiReporting https://github.com/majorsilence/My-FyiReporting
Just like ReportingCloud, My-FyiReporting is a fork of FyiReporting (which has gone dormant).
The big difference as far as you are concerned is that My-FyiReporting has ASP.NET samples and an ASP.NET user control link. This might be the fast way to get to what you need.
File ORIGINALPROJECT.TXT from ReportingCloud says:
The ReportingCloud is a fork from the original project fyiReporting
4.1 (http://www.fyireporting.com).
File readme.md from My-FyiReporting says:
My-FyiReporting is a fork of fyiReporting. I cannot stress this
enough. This is a FORK. The main purpose is to make sure that I have a
copy of fyiReporting since that project seems to be dead.

Web Resource was not found

I've spent the last day trying to get a checkbox validator to work. I found some starting code on the 4GuysFromRolla website, however this was coded back in 2006 and doesn't play alongside updatepanels.
I've made changes and now it works. As I'd made quite a few changes I wanted to standardise it and use it alongside other utility classes, so I created a new class project and copied the code verbatim.
The problem is that the original works, but I get a WebResource not found error on my new class project.
The differences are: The original was a web application project:
my new project is simply a class library project.
The original assembly and namespace have changed.
Both contain a single class and a resource file (.js)
Both resource files are contained in the root directory
Both resource files are set to embed resource
I'm running out of ideas, and have exhausted the answers I've found on the web with no success.
Is there an issue with the fact that its a class library? Have I perhaps overlooked something else?
Its pretty difficult to see beyond those 2 questions because the project is so small and insignificant.
Here's the code that does work:
if (this.RenderUplevel && this.Page != null)
{
ScriptManager.RegisterClientScriptResource(Page, this.GetType(), "skmValidators.skmValidators.js");
}
Here's the code that doesn't:
if (this.RenderUplevel && Page != null)
{
ScriptManager.RegisterClientScriptResource(Page, this.GetType(), "ValidationExtender.EvaluationFunctions.js");
}
Anyone give any ideas?
Thanks in advance.
The error turned out to be a mismatch between the dll's in the test page.

ASP.NET creating resources at runtime

I'm developing an ASP.NET webapp that has a multilanguage feature allowing the webmaster to create new languages at runtime.
The approach that I was thinking is the following:
The user selects one available (not created) language.
When the user confirms, the application automatically copies a set of existing resources, replacing the filename with the new culture. For example: default.aspx.en-us.resx to default.aspx.es-ar.resx.
The user edits the recently created resources.
Currently I'm having troubles with step number 2. I've achieved to copy the resources, but then these new resources are ignored. I think that this happens because the new resources are not included in the running assembly, and therefore are being ignored.
When I test the following code in my local project, I would have to manually add the new resources to the solution and then recompile to make it work.
Does anyone know how to make this work?
This is the code of the mentioned copy.
string _dir = path_ + "App_LocalResources\\\\";
DirectoryInfo _dirInfo = new DirectoryInfo(_dir);
foreach (FileInfo _file in _dirInfo.GetFiles("*en-us.resx")) {
_file.CopyTo(_dir + _file.Name.Replace("en-us", idioma_.Cultura));
}
string _dir2 = path_ + "App_GlobalResources\\\\";
_dirInfo = new DirectoryInfo(_dir2);
foreach (FileInfo _file in _dirInfo.GetFiles("*en-us.resx")) {
_file.CopyTo(_dir2 + _file.Name.Replace("en-us", idioma_.Cultura));
}
Thank you very much.
Creating or editing Resource files is not possible the same way as reading data.
In order to create or edit a resource file, you should do it the same way you create or edit XML files because resource files have with a specific structured XML elements.
Maybe this article will help you...

Can't set up asp.net mvc 2 RC and spark view engine

Does omebody has ideas how to fix "Method not found: 'Void System.Web.Mvc.ViewContext..ctor(System.Web.Mvc.ControllerContext, System.Web.Mvc.IView, System.Web.Mvc.ViewDataDictionary, System.Web.Mvc.TempDataDictionary)'." exception. This solution doesn't work http://dotnetslackers.com/articles/aspnet/installing-the-spark-view-engine-into-asp-net-mvc-2-preview-2.aspx.
Thans for all.
I had to download the spark view engine source code (http://sparkviewengine.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=27600). Once I did that I went through each of the projects that had a reference to the 1.0 version of System.Web.Mvc assembly and updated to reference to point to System.Web.Mvc 2.0. From there you can build the solution (in visual studio) and you will find that a whole bunch of tests start to fail. You can attempt to fix them (by adding the additional TextWriter parameter you will find is now needed). You will also see that the SparkView.cs file complains about a missing parameter. In the Render method (line 100 of the source code I downloaded) I had to update the instantiation of the wrappedViewContext to look like this (add writer to the end of the list of parameters):
public void Render(ViewContext viewContext, TextWriter writer)
{
var wrappedHttpContext = new HttpContextWrapper(viewContext.HttpContext, this);
var wrappedViewContext = new ViewContext(
new ControllerContext(wrappedHttpContext, viewContext.RouteData, viewContext.Controller),
viewContext.View,
viewContext.ViewData,
viewContext.TempData,
writer); // <-- add the writer to the end of the list of parameters
...
}
Once the code is updated you can run the build.cmd script that is in the root of the source you downloaded. The build process will create a zip file in the build/dist folder. Take those new dll's and add them to your website. Things should work once again.
At the time of this answer, MVC 2 RC2 bits are available at sparkviewengine.codeplex.com
http://sparkviewengine.codeplex.com/releases/view/41143
It was actually Erik from the post mentioned by R0MANARMY who helped get those bits out there.
Looks like you can also download compiled binaries from here. As the post says, it isn't a final (or official) release, but at least it seems like the unit tests pass.

Error: is not a valid virtual path

I used something like
Dim i As String
i = Server.MapPath("~/photos/") + fileName
Only once in a project that was working and online, on the offline version, when I run it on my machine, its working, no errors, I uploaded it, it gave me an error like:
'~/photos/http://www.MyURL.com/photos/4411568359267Pic003.jpg' is not a valid virtual path.
Indicating a line in my code:
var marker = new GMarker(new GLatLng(<%=coordinates%>));
This have never happened before, and I don't know where to start troubleshooting as this script -Google Maps- doesn't even need images, i tried to comment it out, it gave me the same error but on a different script this time, the one that show formatting toolbar for the text areas
Line 8: new nicEditor({buttonList : ['fontSize','fontFamily','fontFormat','bold','italic','underline','strikethrough','forecolor','bgcolor','removeformat'], iconsPath : '../nicEdit/nicEditorIcons.gif'}).panelInstance('<%= txtDescription.ClientID %>');
..please HELP :'(
can you post your fileupload aspx page and your function so we can troubleshoot it.
"'~/photos/http://www.MyURL.com/photos/4411568359267Pic003.jpg'"
look closely at the url, it is tacking the full url on to "i". what type of control or you using, a generic or a server side control
solved, turns out the error is due to old database records when i was storing the whole path in the fileName...Thanks Joshua and Keltex

Resources