Why does bpl has Error Loading a resource string after upgrade? - devexpress

We have a bpl that has some resource (.rc) files which has strings in it. It is defined via STRINGTABLE and loaded via a LoadStr() call. The project was in version 10.1 Berlin. We upgraded to the latest 11.1 Alexandria and now the call returns NULL. So to test I added the line at the main
extern "C" int _libmain(unsigned long reason)
{
String str = LoadStr(231); **// Works**
return 1;
}
but the existing code below does not work.
**.h**
PACKAGE String __fastcall GetValueSetDesc(int ACount);
**.cpp**
String __fastcall GetValueSetDesc(int ACount)
{
String ValueDesc = LoadStr(ACount); **// Does not work, retuns NULL**
return ValueDesc;
}
I tried creating the project from scratch (and adding files to it). Any one has experienced this issue or know what to try?

The problem was with DevExpress components. The call was from a DevExpress change event. A call from a non DevExpress component worked fine. The way I solved this is to re-create the cbproj from scratch and add the files, settings etc (in the exe, the bpl seems fine). Man, DevExpress gave me a lot of grief this time around when we upgraded!

Related

.Net 6.0 console application keeps displaying popup message while I am trying to code

I am typing in an example from the book, "C# 10 and .Net 6".
It is a console application with reflection.
Here is the code so far:
using System.Reflection;
Assembly? assembly = Assembly.GetEntryAssembly();
if (assembly == null) return;
// Loop through the assemlies that this app references
foreach (AssemblyName name in assembly.GetReferencedAssemblies())
{
// Load the assembly so we can read its details
Assembly a = Assembly.Load(name);
// declare a variable to count the number of methods
int methodCount = 0;
// loop through all the types in the assembly
foreach (TypeInfo t in a.DefinedTypes)
{
// add up the counts of methods
methodCount += t.GetMethods().Count();
}
//
}
I got this far and was about to type in the last part and I got the popup dialogue in the pic:
It says:
Specified argument was out of the range of valid values.
Parameter name: length
Why does this obtrusive popup keep displaying and stopping me from typing? What is it? What does it mean? Why does it not wait for you to try and build, compile or run before reporting the problem.
What is this and how do you make it go away?
I just want to add I was able to type it all in and the example runs correctly. But why does VS 2022 keep displaying this popup while I am trying to type?
This looks like a problem with Visual Studio or an extension. It's not a problem with your code.
You could try:
Restarting VS,
Restarting Windows,
Repairing/updating/reinstalling VS.

Entity Framework Core SQLite How to use relative Data Source

In a current Project of mine I am using Entity Framework Core together with SQLite in an ASP.Net-Project.
My Problem is, that the Database in the project-files is used, instead of the one in the ./bin-Directory
I followed the instructions of the docs.microsoft-page to create the database:
https://learn.microsoft.com/de-de/ef/core/get-started/overview/first-app?tabs=visual-studio
This is the Connectionstring I am using.
protected override void OnConfiguring(DbContextOptionsBuilder options)
=> options.UseSqlite("Data Source=MySqliteDatabase.db");
I let the created Database be copyied over, when newer.
I browsed through a number of pages, looking for ways to provide a relative Database path, but I couldnt find a solution to this. It either still uses the project-DB-File, or it wont create the new Database, because it cant be opened, or so.
Does anyone have a solution to this? I noticed that Entity-Framework-Core-5 is kind of a new release, could this be a bug or similar of this particular version?
Thanks #Sergey and #ErikEJ.
So to solve this, I really needed to provide the full path of the directory.
Since Directory.GetCurrentDirectory returned the wrong path, that is, the path to the project-directory instead of the /bin/Debug/... , I looked at the path that is named in the Config-File, as #Sergey suggessted, using the following Code:
AppDomain.CurrentDomain.SetupInformation.ApplicationBase
I got this from the following Stackoverflow page:
How to find path of active app.config file?
It said there, to access the ConfigurationFile-Property, but for ASP.Net it is ApplicationBase I guess.
In there was the correct path, the one of the /bin/Debug/... .
Put together, my new Method looked like this:
protected override void OnConfiguring(DbContextOptionsBuilder options)
{
string databasePath = $"{AppDomain.CurrentDomain.SetupInformation.ApplicationBase}MySqliteDatabase.db";
options.UseSqlite($"Data Source={databasePath}");
}
This works for me as intended, thanks alot for the support, maybe this will help someone else as well.

BundleTransformer for less complaining "Could not find a factory, that creates an instance of the JavaScript engine"

If you upgrade from version 1 to version 2 of BundleTransformer you may get this message:
Could not find a factory, that creates an instance of the JavaScript
engine with name MsieJsEngine.
Like me, you may not even have realized you've upgraded more than just a point release.
How to fix?
Version 2 DOES NOT USE WEB.CONFIG for configuration anymore
So start by removing it and read the rest of this link
https://github.com/Taritsyn/JavaScriptEngineSwitcher/wiki/How-to-upgrade-applications-to-version-2.X
Basically you will be doing the following:
Removing existing web.config nodes for javscript engine
Adding to someplace like global.asax some initialization code
Install Nuget packages for the engines you want to use
Make sure to add a using statement to be able to use extension methods (if you choose that way)
I ended up with something like this:
using JavaScriptEngineSwitcher.Core;
using JavaScriptEngineSwitcher.Msie;
using JavaScriptEngineSwitcher.V8;
....
public class JsEngineSwitcherConfig
{
public static void Configure(JsEngineSwitcher engineSwitcher)
{
engineSwitcher.EngineFactories
.AddMsie(new MsieSettings
{
UseEcmaScript5Polyfill = true,
UseJson2Library = true
})
.AddV8();
engineSwitcher.DefaultEngineName = MsieJsEngine.EngineName;
}
}
I'm following the instructions, but my code is now breaking on BundleConfig
var cssTransformer = new StyleTransformer();
In the name attribute of /configuration/bundleTransformer/less/jsEngine configuration element not specified a name of JavaScript engine.
If you have not installed JavaScript engine, then for correct working
of this module is recommended to install one of the following NuGet
packages: * JavaScriptEngineSwitcher.Msie *
JavaScriptEngineSwitcher.V8 * JavaScriptEngineSwitcher.ChakraCore
After package is installed, need set a name of JavaScript engine (for
example, MsieJsEngine) to the name attribute of
/configuration/bundleTransformer/less/jsEngine configuration
element.

New in 4.7.4: QDir::homePath() gives out empty string

QString path = QDir::homePath(); // <-- "path" is always ""
Is this a new bug in 4.7.4? use to work well in 4.7.3
I’m on OSX Lion (4.7.3 worked on Lion well).
The “Clear System Environment” probably cleared the HOME environment variable too.
Basically, QDir::homePath() returns QFile::decodeName(QByteArray(::getenv("HOME"))) almost unchecked. And that's an empty string, if there is no HOME variable.
Hmmm It seems the problem is resolved if I don’t use the “Clear System Environment”. I unchecked it, then re-built and it worked fine. could it be the “SHELL” definitions? I can’t think of anything other than that that’s remotely related to this. I guess something caused Qt to have QT_NO_FSFILEENGINE defined and thus to return an empty string:
// from Qt source file: QDir.cpp
QString QDirPrivate()
{
#ifdef QT_NO_FSFILEENGINE
return QString();
#else
return cleanPath(QFSFileEngine::homePath());
#endif
}

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.

Resources