We are developing a multilingual Winforms application using visual studio 2008. I am trying to figure out how I can create multilingual reports using crystal Reports.
Is there any thing similar to .net resource files in the Crystal reports world?
I'm sorry that I'm robbing you of your tumbleweed badge, but I don't think Crystal has the multiple language support similar to .NET. I think that your only option is to have a separate report for each language and pass the data into the report in the language that you wish to display.
Here is a link of a similar answer.
http://www.dbforums.com/crystal-reports/991737-crystal-report-multillingual-support.html
This would be a manual way of doing this:
Create a report for each language you want and put into the proper folders structure. i.e. all japanese reports will go into rpt_ja/ folder.
Use .Net Resource file to specify report resource name and full resource name for each language:
resource.resx
RPT_SAMPLE -> report01.rpt
RPT_SAMPLE_FULL -> MyCompany.NameSpace.Reports.Report01.rpt
resource.ja.resx
RPT_SAMPLE -> rpt_ja\report01.ja.rpt
RPT_SAMPLE_FULL -> MyCompany.NameSpace.Reports.Report01.ja.rpt
Then use this value in the report code file: Open the report .cs file and change:
public override string ResourceName {
get {
// Change this to HttpContext.GetGlobalResourceObject("Resource", "RPT_SAMPLE").ToString();
return "report01.rpt";
}
set {
// Do nothing
}
}
public override string FullResourceName {
get {
// Change this to HttpContext.GetGlobalResourceObject("Resource", "RPT_SAMPLE_FULL").ToString();
return "rpt_ja\report01.ja.rpt";
}
set {
// Do nothing
}
}
EDIT: HttpContext is for ASP.Net web application. In winform, you can try Properties.Resources.ResourceManager.GetString() to get the string from resources
A client ask me for a solution to this issue. I developed a solution based on Crystal Reports contentLocale keyword and Custom Functions. See my posting: http://www.cogniza.com/blog/?p=55.
Related
Deleting bin and obj folders, cleaning solution, and restarting studio did not help.
Designer does open a base form.
Inherited form (FrmBase) has an empty constructor and no parameters. Some of the derived forms have and some do not have an empty constructor, constructor with or without parameters, the error is the same for all.
FrmBase is in another project.
Update 2022-08-05: when I copy the exact form file with its designer, change the name of the class and it works. 😐 But I don't want to do that for a hundred+ forms in my solution. I also looked at differences in the project file for those forms and there is none.
The Extender Provider failed to return an Extender for this object.
Instances of this error (1)
Hide Call Stack
at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
at Microsoft.VisualStudio.LanguageServices.Implementation.ProjectSystem.InvisibleEditor..ctor(IServiceProvider serviceProvider, String filePath, IVsHierarchy hierarchy, Boolean needsSave, Boolean needsUndoDisabled)
at Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.TextManagerAdapter.CreateTextPoint(FileCodeModel fileCodeModel, VirtualTreePoint point)
at Microsoft.VisualStudio.LanguageServices.Implementation.CodeModel.InternalElements.AbstractCodeElement.get_StartPoint()
at EnvDTE.CodeClass.get_StartPoint()
at Microsoft.DotNet.DesignTools.Client.CodeDom.VsCodeDomProvider.Parser.ProcessClass(CodeClass vsClass, CodeNamespace namespace)
at Microsoft.DotNet.DesignTools.Client.CodeDom.VsCodeDomProvider.Parser.ProcessNamespace(CodeNamespace vsNamespace, CodeCompileUnit compileUnit)
at Microsoft.DotNet.DesignTools.Client.CodeDom.VsCodeDomProvider.Parser.ProcessFileCodeModel(FileCodeModel fileCodeModel, CodeCompileUnit compileUnit)
at Microsoft.DotNet.DesignTools.Client.CodeDom.VsCodeDomProvider.Parser.Parse(TextReader codeStream)
at Microsoft.DotNet.DesignTools.Client.CodeDom.MergedCodeDomProvider.Parser.System.CodeDom.Compiler.ICodeParser.Parse(TextReader stream)
at Microsoft.DotNet.DesignTools.Client.CodeDom.CodeDomSource.get_CompileUnit()
at Microsoft.DotNet.DesignTools.Client.CodeDom.CodeDomManager.GetDeclarations()
at Microsoft.DotNet.DesignTools.Client.Loader.VsDesignerLoader.PerformServerLoad()
at Microsoft.DotNet.DesignTools.Client.Loader.VsDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at Microsoft.DotNet.DesignTools.Client.Loader.VsDesignerLoader.DeferredLoadHandler.PerformLoad()
Help with this error
Could not find an associated help topic for this error. Check Windows Forms Design-Time error list
Forum posts about this error
Search the MSDN Forums for posts related to this error
The problem was that I have another .NET Framework project that has those forms linked from .NET6 project. When I just copy the form to .NET Framework project, the problem is resolved.
I'm testing localization in Nancy and able to get it to work using EMBEDDED resource files but the issue is I don't want embedded resource files because I want them to be allowed to be edited via the GUI or using the file (if I go the DB route or setting the resource file as "content").
According to the doucmentation you should be able to override it to support using a database but I'm unable to get this to work (https://github.com/NancyFx/Nancy/wiki/Localization):
public class ResourceManager : ResourceBasedTextResource
{
public ResourceManager(IResourceAssemblyProvider resourceAssemblyProvider) : base(resourceAssemblyProvider)
{
}
public new string this[string key, NancyContext context]
{
get
{
return "HELO!";
}
}
}
This was just me messing around but I was hoping in the Razor view when I did #Text.Localization. it should return "HELO!" for everything... however it is not working
There really isn't a question in your post so I'm going to have to guess a bit and assume that you're not getting any exception but rather you're not seeing the "HELO!" in your view
Simply implementing a new ResourceBasedTextResource class is not enough. This is a core component and as such you are going to explicitly have to tell Nancy to use it. You do this by overriding the InternalConfiguration property of your Bootstrapper and tell Nancy to use your implementation instead
You can see it in the DemoBootstrapper of the demo that is linked from that wiki page https://github.com/NancyFx/Nancy/blob/8970ac9d6c7cf46e6060f0b83117c19fa18085c2/src/Nancy.Demo.Razor.Localization/DemoBootstrapper.cs#L11
Also, if you are not going to use resource files, then you should look into inheriting from ITextResource interface instead. It's a simple interface so it should be straight forward.
HTH
I have a application previously developed in Visual Studio Express 2010. It uses localized winforms and resx resources used in code.
When the project is opened and compiled using Visual Studio Express 2012 on the same computer the localized strings are not applied, only the default code was found.
The application runs fine and in the winforms designer I can change language to see and edit the localized text of the controls.
I also tried the following code to determine if the languages used were there at runtime, which did report the ones used.
CultureInfo[] cultures = CultureInfo.GetCultures(CultureTypes.AllCultures);
foreach (CultureInfo culture in cultures)
{
try
{
ResourceSet rs = resources.GetResourceSet(culture, true, false);
// or ResourceSet rs = rm.GetResourceSet(new CultureInfo(culture.TwoLetterISOLanguageName), true, false);
if (rs == null)
continue;
string isSupported = (rs == null) ? " is not supported" : " is supported";
Console.WriteLine(culture + isSupported);
}
catch (Exception)
{
Console.WriteLine(culture + " is not available on the machine or is an invalid culture identifier.");
}
}
Still when the application is running all I get is the resources for the default language.
I retrieve the resources using:
ResourceManager resources = new ResourceManager(form.GetType());
form.Text = resources.GetString("$this.Text", lang);
where I have verified that lang is correct, but also using
System.Threading.Thread.CurrentThread.CurrentUICulture = lang;
System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(lang.Name);
followed by usage of MyLangResxFile.MyStringResource.
The strings returned are still only the default ones.
Might there be changes or limitations in resx localization support between Visual Studio Express 2010 - 2012?
Update:
I noticed that the localisation works if compiled using msbuild.exe from 3.5 but when using 4.0... the localisations are missing as described above.
sorry for "answering" that question but commenting is not working.
I just want to ask if you could solve that issue in the meantime because I have exactly the same issue.
I even noticed that this issue only happens when target framework < 4.0 is selected. For target framework 4.0 and 4.5 localization is working as before in VS 2010...
How do I use the word editor in a WPF application? Is it possible using windows forms hosting in WPF only? Is there another way to accomplish that?
I found AvalonEdit but it does not have features that I need. So using this way, my problem may not be solved.
Also there is some stuffs out there to host a windows forms control in WPF, but it could not be my answer.
I want to understand that is there a way to use word editor in a native way in a wpf app?
Will all APIs be available in that solution?
Thanks in advance.
You can host MS Word (2007/2010 and probably other versions) from within a WebBrowser control, this works in WinForms and should work in WPF too. A .NET API is provided for automating Word, documented here. The required interop assemblies ship with Office 2010, so deployment is a lot simpler than previous Office versions.
See this Microsoft Support article for more details on hosting Word within a WebBrowser control. The Screenshot below shows Word embedded within a host Winforms application.
Note that this only works reliably for a single hosted instance of Word, so you can't show 2 Word documents side by side in the same application. Also, the Ribbon can sometimes go missing - but Word hasn't ever caused the application to crash.
Administrative rights are required to make the required registry updates as there are potential security issues. One easy method to make the registry updates is to write a script, but the following (revised/untested) code shows how this can be done in c# for Word, Excel and PowerPoint:
using System.Security.AccessControl;
private Dictionary<string,uint> OfficeBrowserRegKeys()
{
string[] officeRegKeyArray = new string[]
{
#"SOFTWARE\Classes\Word.Document.12",
#"SOFTWARE\Classes\Word.DocumentMacroEnabled.12",
#"SOFTWARE\Classes\Excel.Sheet.12",
#"SOFTWARE\Classes\Excel.SheetMacroEnabled.12",
#"SOFTWARE\Classes\Excel.SheetBinaryMacroEnabled.12",
#"SOFTWARE\Classes\PowerPoint.Show.12",
#"SOFTWARE\Classes\PowerPoint.ShowMacroEnabled.12",
#"SOFTWARE\Classes\PowerPoint.SlideShow.12",
#"SOFTWARE\Classes\PowerPoint.SlideShowMacroEnabled.12"
};
Dictionary<string,uint> officeRegKeys = new Dictionary<string, uint>();
uint wrdVal = 0x80000024;
uint excelVal = 0x80000A00;
uint powerPtVal = 0x800000A0;
foreach(string keyName in officeRegKeyArray)
{
if (keyName.Contains("Word"))
{
officeRegKeys.Add(keyName, wrdVal);
}
else if (keyName.Contains("Excel"))
{
officeRegKeys.Add(keyName, excelVal);
}
else
{
officeRegKeys.Add(keyName, powerPtVal);
}
}
return officeRegKeys;
}
private void setNewOfficeKeys()
{
uint editFlag = 0x00010000;
Dictionary<string,uint> officeRegKeys = OfficeBrowserRegKeys();
foreach (KeyValuePair<string, uint> kvp in officeRegKeys)
{
try
{
RegistryKey rKey = Registry.LocalMachine.OpenSubKey(kvp.Key,
RegistryKeyPermissionCheck.ReadWriteSubTree,
System.Security.AccessControl.RegistryRights.SetValue);
rKey.SetValue("BrowserFlags", unchecked((int)kvp.Value),
RegistryValueKind.DWord);
rKey.SetValue("EditFlags", unchecked((int)editFlag),
RegistryValueKind.DWord);
}
catch (Exception e) { string msg = e.Message; }
}
}
Well, Word proper isn't technically designed to be hosted by another app, whether it's WPF, WINFORMS or anything else.
You CAN use api tricks (like SetParent) to move the Main Word window into a WPF hosted window. I've done it before, but it's pretty tricky business and it's very easy to miss things that cause GPFs (both in Word and your app).
Is there any reason why it needs to be "Word in your app"? Why not write a little word addin and then launch Word from your app when necessary. then the Addin can communicate with your app, or your DB or whatever as necessary from within Word.
Users may find that to be a more usable approach in any case.
In Microsoft Reporting Services, I want to be able to name the tabs for the resulting document when a excel report is generated.
Does anyone know how I can do this?
To get around this issue from the web front end (which drove me crazy using the ReportViewer web control), I realised that SSRS returns the data as a byte array that you can then process. So capturing the stream in .NET you can write a method that does something like:
private byte[] ExportStream(string streamType, out string mimeType, out string extension)
{
Microsoft.Reporting.WebForms.Warning[] warnings;
string[] streamids;
string encoding;
string deviceInfo = "<DeviceInfo><SimplePageHeaders>True</SimplePageHeaders></DeviceInfo>"
byte[] bytes = ReportViewerClientReport.ServerReport.Render(streamType,
deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings);
return bytes;
}
Then post-process the output from this method with something like the fantastic NPOI library from http://npoi.codeplex.com/ either as bytes or create some kind of memory stream, then you can make it do whatever you want.
Also- note that SSRS (Sql Server Reporting Services) R2 will have this feature, but it comes out in about May 2010. http://www.bidn.com/blogs/bretupdegraff/bidn-blog/234/new-features-of-ssrs-2008-r2-part-1-naming-excel-sheets-when-exporting-reports
If you want to break up a report in tabs when exporting, use mutiple tables with page breaks.
You can not rename tabs from SSRS. If you want to rename the tabs you will need to write custom code.