adding user defined unt to other lazarus project - lazarus

my problem is i successfully adding my defined unit in delphi2.0 project but in lazarus project i do not know how to enter path of my unit'D:\Lazarus\Pantip' to
other project.because the explanation in stack overflow did not indicated that where to put it on path editor or other unitfiles(-Fu) meanwhile the name of project has already in target file name. my question seem to be a silly
one but in thailand there is almost no Delphi or Lazarus code writer so i have no choice but to consult outsiders for responding my difficulty.

Add the path to the "unit path" line (-Fu) (I assumed "pantip" is part of the path, not the unit name)
Simply put the name of the unit in your uses clause

Related

How is classes.php written when developing a plugin

I'm developing an October CMS plugin, say author.pluginname, on a windows platform.
The file storage/framework/classes.php is meant to be auto-generated with the links of my classes, correct?
I'm not sure if that is always the case and I don't know if I need to or how to force it happen. The two cases were : 1) I just created a new class, 2) I rsynced my plugin to another test (linux server).
For example, I just copied my plugin to a new October CMS installation but and after installing the plugin with plugin:refresh, it doesn't appear in the classes.php file.
I visit a page where a component is being used and I get a class not found error:
"Class 'author\plugin\Models\modelx' not found" on line 653 of /pathtowww/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Concerns/HasRelationships.php
when I grep my author, it finds some classes but not all:
grep -i author storage/framework/classes.php
I had to add it manually to make it work but I assume this is not what we should be doing. So is there something I ought to be writing in the Class file or 'registering' in the Plugin.php folder?
Note this plugin is not in the Marketplace (obviously as it's not developed).
Also, when I create a new class with the Builder plugin, it does appear in the classes.php. When I create it with my text editor, it often does not. Apologies if that is obvious but I'm quite confused....!
I have found the issues' solution(s), in case anyone runs into these problems.
1) If using Windows + another operating system, make sure the folder/file names are in the correct case. Windows is case insensitive so a typo will not result in an error until you migrate to Linux / OSX
2) Classes.php is generated automatically ONLY if the namespace matches the directory structure of your file. So if you move the file (or have the wrong namespace), classes.php will not be generated and you will get a class not found.

How do you set Resource Logical Name in Visual Studio 2010?

I have a problem when migrating a solution from VS2008 to VS2010. The problem is that the managed resources are not found in some cases in runtime, since they are not embedded with the correct name:
"Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Production.ViewDocument.resources" was correctly embedded or linked into assembly "RSProcess" at compile time, or that all the satellite assemblies required are loadable and fully signed."
System.Resources.MissingManifestResourceException is typically thrown InitializeComponent in a call to ApplyResources on a resource that is created passing the type id. In my case the namespace is Production and the class name is ViewDocument. However, the resource generated (from the ViewDocument.resx) is named from the folder structure where the resx file is, in this case Production.folder1.folder2.ViewDocument.resources.
In VS2008 you could override the (default) logical name in in a setting on the .resx file, Managed Resources/General/Resource Logical Name. In VS2010 I cannot get this to work - it simply ignores this setting completly! Is there any ohter way of solving this?
One last resort would be to remove the current folder structure and move all files to the root project folder, but this seems to be quite a lot of work in my case.
Any suggestions?
I have found an answer to my own question!
A couple of things has changed in VS2010 that confused me. First, in VS2008 the names of the .resource files were affected by the project setting 'Resource Logical Name', in VS2010 the files are always named according to the root namespace of the project and the folder structure (extended namespace). Second, when migrating, these settings were blanked out, perhaps because we had used a macro $(InputFile) that has been replaced by %(Filename).
To fix this problem, I defined 'Resource Logical Name' on the project level (or you could use project property pages) to $(RootNamespace).%(Filename).resources. Note that the .resource files still get the extended names (defined by in which folder they reside). However, if you check the log file from MSBuild you can see that the logical name appears in the /ASSEMBLYRESOURCE swich to the linker in addition to the resource file name! After rebuilding, the ComponentResourceManager will now find the resources in 'InitializeComponent' using the type for the view, Rootnamespace.filename in this case. Also note that this assumes that your view classes are placed in files with the same name as the class!

VS2010 not embedding files into assembly

For some reason in VS2010 I can't embed any file into an assembly. These files have their Build Action property set to Embedded Resource as they should, but when the assembly is executed it founds no resources. For example, the following test code:
string[] list = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceNames();
string msg = (list.Length > 0) ? "Full" : "Empty";
MessageBox.Show(msg);
always shows "Empty" because GetManifestResourceNames() always returns an empty list.
This issue affects a project using nettiers in which is not convenient for that particular case to include the stored procedures into the DB, so they must be taken from the Procedures.xml file, which BTW is automatically set with Build Action= Embedded Resource after the classes generation, and then of course when a function tries to get any SQL script from it, the program fails.
I also created a couple of test projects where I tried to embed an xml and a gif, always with no success.
Update: The problem seems to be only for C#. I reproduced the test project in VB.Net and there the file does get embedded. I've noticed that in the output window, in the C# case, the compiler command line doesn't include the /resource option (which should be there followed with the name of the file to embed) whereas for the VB case it does appear.
Are there any global settings or configuration files anywhere for C# I should check? (The build options for the project have nothing strange there)
Does anyone have an idea of what may be happening and how to fix this?
Finally, I found the cause:
There was a wrong line inside the Microsoft.CSharp.targets file (located inside c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319). There was a tag written as:
<EmbeddedResourceF Include="#(_Temporary)" />
instead of
<EmbeddedResource Include="#(_Temporary)" />
Writing it right restored the ability to embed files
How that F appeared and why that file got altered in first place, I dont know... Despite being a .NET programmer for several years I just became aware today of the ".targets" files after searching the web about this issue, as never have had the need to look about the MSBuild stuff.

Set the default description for custom build rules in Visual Studio (2008)

In VS, it is possible to set a custom build rule at the individual file level. However, unless you change the description of the build step (which is what msbuild outputs when running the external tool), all you get is the default, which says "Performing Custom Build Step," followed by the error output of the tool.
I recently got burned by this in an inherited solution, where the build rule for a .asm file buried deep in a project was failing, and NASM didn't provide any useful debug information. Since I didn't know what file was failing, it took me forever to find the problem. One thing I tried was changing the description for all the projects in the solution (by selecting them all at once and opening the properties panel) and adding macros to show the project and file affected. Since the build rule was attached to a file, however, this naturally didn't work.
I also tried searching for the default description string in all the project files, but the project files don't store this information unless you set the value. So clearly, there's got to be a default somewhere. Anyone know how you can set this?
I doubt you can change the default for everything, but what you can do is create a property sheet in which you set a custom description, and than add that property sheet to all projects needing it.

My.Resources in Class Library not behaving as expected when deployed

ASP.NET application w/CSLA framework; Visual Studio 2008
I have a class library of business objects. I am storing the broken rules strings in the Resource file associated with the project (My Projects > Resources.resx). I added a new resx file to the project and named it Resources.fr-CA.resx to store the french language equivalents of the rules.
I am calling the strings with the My.Resources object, like this:
e.description = My.Resources.BrokenRulesString
This works like a charm when I run the application locally (i.e. hit "play" in Visual Studio). However, when I build and deploy the application to another environment I always get the values in the default resource file.
Even if I explicitly set the culture to "fr-CA" in the Resources.Designer.vb file, like this, the property returns the string from the default resource file:
Public ReadOnly Property BrokenRulesString() As String
Get
Return ResourceManager.GetString("BrokenRulesString", "fr-CA")
End Get
End Property
It looks to me like the application can't see the fr-CA resource file so defaults to the... default file. Any tips to get this working?
Thank you.
You need to make sure the satellite assembly containing your localized strings is deployed in the correct directory structure. See this MSDN article for details.
From the article:
After you have compiled your satellite assemblies, they all have the same name. The runtime differentiates between them based upon the culture specified at compile time with Al.exe's /culture option and by each assembly's directory location. You must place your satellite assemblies in expected directory locations.
Ultimately it came down to the fact that I hadn't added the proper Project Output Group (Localized resources) for the Business.Library project to the setup project. I added it to the bin folder and now the deployed application works like a charm as well.
Oded, thanks for getting my head pointed in the right direction. Cheers!

Resources