|
I suspect that your build has actually gone into the app/out folder rather than the app folder.
|
|
|
|
|
Thanks Pete what can I do to change that ?
Edit I managed to suss it I out think, well it runs
Get Base Image (Full .NET Core SDK)
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
WORKDIR /app
Copy csproj and restore
COPY *.csproj ./
RUN dotnet restore
Copy everything else and build
COPY . ./
RUN dotnet publish -c Release -o out
Generate runtime image
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "AllValvesAPI.dll"]
"I didn't mention the bats - he'd see them soon enough" - Hunter S Thompson - RIP
modified 20-Nov-20 11:08am.
|
|
|
|
|
Hi, I have a Windows app which contains some text boxes as inputs and a DGV. I can export the DGV content to Excel file. I want my app to load my previous contents in DGV automatically ,when I run the app . How can I achieve this goal? The save file should be addressed where the main EXE file exists.
|
|
|
|
|
Alex Dunlop wrote: The save file should be addressed where the main EXE file exists.
That won't work if your application is installed in the "Program Files" directory. Regular users don't have permission to write to folders in that location.
Where Should I Store My Data?[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Quote: The save file should be addressed where the main EXE file exists
No, it shouldn't.
That's a rookie mistake: it works in development but fails in production because the EXE file is stored under a subdirectory of "Program Files" and that folder is protected by default to prevent or at least reduce virus activity. So when you app truies to write a new version, it can't and you app fails. See here: Where should I store my data?[^] for some better ideas.
Actually restoring the data isn't complicated: read the Excel file and load the DGV in the Form Load or Show event. Stroe the path to the Excel data in teh EXE config file, and you can save and restore it to the same place.
But you are still using the DGV directly, instead of the underlying data which is a mistake.
As I explained last time, your DLL based "write to Excel" code needs to be passed something, and a DataTable is much better than a DGV - so add code in that assembly to read it back out and into a DataTable. Then return the DT and your EXE can use that as the source for your DGV.
It really does make life eaiser, even if it means you making small changes to existing code!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
The problem coexists with DataTable is that I cannot change text font of cells. And because of the language I'm using (Persian), I need to perform RightToLeft function. It's so easy in DataGridView's native properties but I don't know hpw to change font, alignment, and RightToLeft properties in DataTable.
|
|
|
|
|
That's a presentation function, not data related - and should be solved separate to the data by setting the default cell style (including font) on the DGV before or after you load the data.
You are mixing this stuff up far too much: if you need to change from a DGV to different controls, that formatting will not carry with it anyway!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
"Common sense is so rare these days, it should be classified as a super power" - Random T-shirt
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
The problem coexists with DataTable is that I cannot change text font of cells. And because of the language I'm using (Persian), I need to perform RightToLeft function. It's so easy in DataGridView's native properties but I don't know hpw to change font, alignment, and RightToLeft properties in DataTable.
|
|
|
|
|
Listen to what OG is saying, treat the data and the formatting/presentation as two distinct issues. Store the underlying data set, probably as CSV in the users data folder and format the DGV using the DGV properties when loading the stored data.
DO NOT ATTEMPT TO STORE THE FORMATTING!
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
I have a .NET 5 console app, which has an App.config (with EF / database connection strings in it).
It works fine, but if I publish as a single file it doesn't work, i.e. it doesn't read the app.config file..
I even specified that the App.config is not embedded in single file deploy, like so in the .csproj
<ItemGroup>
<None Update="*.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
</None>
</ItemGroup>
What else could I be missing!?
|
|
|
|
|
Are you sure it's renaming the config file correctly? With that setting, it looks like the file in the output directory will be called app.config , but it needs to be called YourApp.dll.config or YourApp.exe.config .
What happens if you remove the <None> element from the project file?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
yea, yeah, once deployed, with that flag / .csproj change, it has both files, i.e. "app.config", and "<myproj>.dll.config" but fails to read any of them anyway!
|
|
|
|
|
There is no "App.Config" at runtime; it's xxx.exe.config.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Surely you mean <project name>.dll.config? (.net core and .net5, remember!)
Which is the one I have, obviously! VS didn't do any joke on me!
But, just to be sure I did rename it <project name>.exe.config, didnt run either
This seems to be very specific to single file deployment btw, I think you missed that.
|
|
|
|
|
In my case, the "build" creates it in the Debug and Release folders. One doesn't simply rename something.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Are you trolling?
If not, you are not helping.
Word of advice, get familiar with Visual Studio or MSBUILD. It does all the trivial renaming and such for you, there is no ambiguity except in your mind.
Also get familiar with .net core / 5.
it's .DLL.config.
UNLIKE .NET Framework 4 and before, which was .exe.config
modified 18-Nov-20 6:32am.
|
|
|
|
|
Got you.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
I have a bunch of messages in a Constants file that I want to convert all string constants for messages displayed to users to be moved to a localized/globalization resource file.
I created a Resources.resx file and I'm trying to figure out how to reference a resource in a controller. For example this resource in my Resources.resx file
internal static string ExamItemResponseAddSuccessfully {
get {
return ResourceManager.GetString("ExamItemResponseAddSuccessfully", resourceCulture);
}
}
I want to reference it in a controller POST action to replace the bolded reference to the string constant in the method below. How do I reference the resource above in the method below.
public async Task<IActionResult> CreateDorItemResponse(CreateEditDorItemResponseViewModel dorToCreateItemResponse, CancellationToken cancellationToken)
{
var newDorItemResponse = new DorItemResponse();
if (ModelState.IsValid)
{
try
{
var item = await _dorService.GetItemAsync(dorToCreateItemResponse.ItemId, cancellationToken)
.ConfigureAwait(true);
_mapper.Map(dorToCreateItemResponse, newDorItemResponse);
newDorItemResponse.CreatedBy = User.Identity.Name;
newDorItemResponse.ModifiedBy = User.Identity.Name;
await _dorService.CreateEditItemResponse(newDorItemResponse, User.Identity.Name, cancellationToken).ConfigureAwait(true);
TempData.Put(TempDataKey.Dor.RESPONSE_ADD_MESSAGE, StatusMessageModel.Create(Constants.Dor.RESPONSE_ADD_SUCCESS, false));
return RedirectToAction(nameof(EditDorItem), new {id = item.ItemId, dorId = item.DorId});
}
catch (Exception)
{
TempData.Put(TempDataKey.Dor.RESPONSE_ADD_MESSAGE, StatusMessageModel.Create(Constants.Dor.RESPONSE_UPDATE_FAIL));
}
}
return View(dorToCreateItemResponse);
}
|
|
|
|
|
Something like this should work:
TempData.Put(TempDataKey.Dor.RESPONSE_ADD_MESSAGE, StatusMessageModel.Create(Properties.Resources.ExamItemResponseAddSuccessfully, false));
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Richard Deeming wrote: TempData.Put(TempDataKey.Dor.RESPONSE_ADD_MESSAGE, StatusMessageModel.Create(Properties.Resources.ExamItemResponseAddSuccessfully, false));
I'm trying to replace the TempData.Put(TempDataKey...) stuff because I that is in the Constants file and I'm getting rid of that altogether.
I want to have the message come from the Resources file.
|
|
|
|
|
As far as I can see from your question, the values in the TempDataKey class represent the key of the TempData item. The message constants are defined in the Constants class, which is why I replaced that constant with the value from the resource file.
The TempData key will never be shown to the user.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Hello - I am constructing an URL to pass for API call.
It has a date value in it.
DateTime.Today.AddDays(0).ToString("yyyy-MM-dd")
Is there some way I can pass the (0) dynamically, reading from App.Config file?
I tried --
DateTime.Today.AddDays(ConfigurationManager.AppSettings["CompletedDays"].ToString("yyyy-MM-dd") which errored out and did not work. Any way to do this?
Thanks!
|
|
|
|
|
Member 14474607 wrote: which errored out and did not work. Sorry, there is no way we can guess what that means. Please edit your question and provide proper details of the problem.
|
|
|
|
|
var revisedDateTime = DateTime.Now.AddDays( (int) ConfigurationManager.AppSettings["CompletedDays"] );
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
The AppSettings indexer returns a string . The code will compile, but will throw an InvalidCastException at runtime.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|