Trouble creating Object Data Source - c#

I'm using VisualStudio 2012. I wanna create a demonstration project to be deployed in IIS.
This project must have an aspx page with a ReportViewer which will show a local processing report. By local report, I mean it won't use Reporting Service, the project's compiled code must build its own report.
I'm using the tutorial at http://msdn.microsoft.com/en-us/library/ms251784.aspx
But when I create a report from Report Wizard, "Choose a Data Source Type page" isn't shown. I'm presented to the "Choose Your Data Connection page", where I should set a connection to a DBMS.
I don't wanna create the report from a DBMS, I want an Object Data Source. It will be a List of Plain Old C# Classes, that will be fed to the report. I don't want the report viewer to access the DBMS directly.
BusinessObjects.cs was properly created and it's in the root of the project.
I F6 compiled the solution, cleaned it, closed VS and reopened. It simply doesn't let me create a data source that's not from a DBMS.
Is there anything the tutorial ommited and I'm missing?

I solved it.
I created a new project with a "ASP.NET Empty Web Application" template. Inside the solution I created another project with a "ASP.NET Server Control" template.
I used the serve control project as application layer, and the empty webapp project as presentation/UI layer.
In application project I created the Object Data Source and added that project to UI project's reference. With that I was able to create an asp page in UI project that consumes the application object data source.
GG

Related

Scaffolded Identity pages are not being used. It appears that the site is delivering the pages from the un-scaffolded razor class libraries

I have a solution where I am trying to move the scaffolded Identity razor pages from the web site project to a different project, so that they can be shared by a couple of different web site projects scheduled for the next phase of development.
Problem: The scaffolded Identity pages are not being used. It appears that the site is delivering the pages from the un-scaffolded razor class libraries.
What I have so far:
A solution containing an ASP .NET Core Web App (MVC) which targets the framework .NET 6.0. It was created with an Authentication type of Individual Accounts. Visual Studio did it’s magic and produced all the code and dependencies as expected.
Next, I scaffolded in the Identity pages, which produced the Data and Areas folders containing a migration with the dB Identity tables and the razor pages respectfully.
Next, I added a new project to the solution. I removed the initial class1.cs that the template creates by default.
To this new project I cut and pasted the Data and Areas folders from the web site project to the new project.
I then added in all the appropriate dependencies to the new project.
enter image description here
Next, I updated the namespaces in:
all the razor .cs pages under /Areas/Identity/Pages, /Areas/Identity/Pages/Account and /Areas/Identity/Pages/Account/Manage to match the folder structure in the new project
the #using in the three _ViewImports.cshtml files which exists in all three folders
ApplicationDbContext.cs
enter image description here
Next, I added to the web site project a reference to the new project with the Identity pages.
enter image description here
Then, I opened Package Manager Console and set the new project as the Default project.
Then, I executed PM> update-database.
The solution compiled with no issues and the output indicated the database and tables were successfully created.
I checked the database and all the expected Identity tables were created in the new database.
enter image description here
Just for reference, here is contents of program.cs
enter image description here
Lastly, I modified the login.cshtml file in the new project, simply changing what is contained within the h2 tag.
enter image description here
Thanks for staying with me so far.
Finally, I ran the project from Visual studio and navigated to the login page.
The modified login page was not displayed.
enter image description here
I have no screen shots for the following but I did these simple debugging steps:
moved the Identity razor pages back to the website project and the modified page was displayed.
put the Identity razor pages back into the new project and they were not displayed.
Went ahead and registered and logged in. It all worked fine.
Logged out.
Added a [Authorized] tag to the home controller.
Compiled the solution and ran it from Visual Studio again.
It, as expected, delivered the login page instead of the home/index page but again it delivered the page from un-scaffolded razor class libraries and not the modified page in my separate project.
I have done this successfully in prior projects but those project targeted earlier versions of NetCore and MVC.
What am I missing?

How to create an ASP.NET Core MVC boilerplate from a custom base project

Like a lot of developers, I often create new projects with the same features (Authentication, IoC, tests etc..).
What I want to do?
I would like to be able to create a new project based on a custom template code project.
What kind of project?
Currently I'm creating a lot of new in ASP.NET Core MVC projects.
My goal is to generate those new project from a specific template (with some configuration options like the project name).
It's possible in the JavaScript world (with some command lines like expo init my-react-native-project). So is it possible to do it for ASP.NET Core MVC projects?
I hope what I want to do is correctly explained :)
Thank you very much for your help.
You can create a custom template from an existing project by adding a .template.configtemplate.json file
Essentially, you can setup the project to have all of the common functionality you required i.e. Authentication, test, IOC and re-use this in a new project.
Have a look at this post for futher details:
https://devblogs.microsoft.com/dotnet/how-to-create-your-own-templates-for-dotnet-new/
taken from https://learn.microsoft.com/en-us/visualstudio/ide/how-to-create-project-templates?view=vs-2019
This topic shows you how to create a template using the Export Template Wizard, which packages your template in a .zip file.
Use the Export Template Wizard
Create a project.
Note
Use only valid identifier characters when naming a project that will be the source for a template. Otherwise, compilation errors can occur in projects that are created from the template. For more information about valid identifier characters, see Declared element names (Visual Basic) or Identifiers (C++). Alternatively, you can use Template parameters to use "safe" names for classes and namespaces.
Edit the project until it is ready to be exported as a template. For example, you might want to edit code files to indicate where parameter replacement should take place. See How to: Substitute parameters in a template.
On the Project menu, choose Export Template.
The Export Template Wizard opens.
On the Choose Template Type page, select Project Template. Select the project you want to export to a template, and then choose Next.
On the Select Template Options page, enter a name and optional description, icon, and preview image for your template. These items will appear in the dialog box where you create a new project. Choose Finish.
The project is exported into a .zip file and placed in the specified output location, and, if selected, imported into Visual Studio.
To find your template in the dialog box where you create a new project, search for it by name or scroll through the list. (Filtering based on language or project type is not currently possible for user templates.)
Other ways to create project templates
You can create project templates manually by gathering the files that constitute the project into a folder and creating a .vstemplate XML file with the appropriate metadata. For more information, see How to: https://learn.microsoft.com/en-us/visualstudio/ide/how-to-manually-create-web-templates?view=vs-2019
If you have the Visual Studio SDK installed, you can wrap the finished template in a VSIX file for deployment by using the VSIX Project template. For more information, see https://learn.microsoft.com/en-us/visualstudio/extensibility/getting-started-with-the-vsix-project-template?view=vs-2019.

Changing assembly name broke xaml namespace

I have some application named Application.exe. I use it for showing a different type of documents. Each document type template is a single dll-file with wpf user controls and business logic inside. So when I started my application, I download xml-file and Template.dll and then I show some wfp-form for work.
My Application.exe and Template.dll both use some assembly named Application.CustomControls.dll. I include it in setup project for application, so Application.CustomControls.dll is already in the application domain when my Application.exe tries to show the document.
Now my client demands to change Application.CustomControls.dll name to CustomControls.dll. Don't ask, please. Just assembly's file name, not namespace or something.
I can do it for application without problems. I can rebuild a solution and create setup project with newly named dll-file. But I can't open old templates case they all have old name inside. Especially in xaml like:
xmlns:Controls="clr-namespace:CustomControls.Design;assembly=Application.CustomControls"
I can't just rebuild all templates. It will be done, but in prod, there is always will be the time when some users forgot to upgrade their soft and so on. So either old application couldn't open the new template, or new application couldn't open an old template.
I didn't change namespace, or version of Application.CustomControls.dll just name. Could I somehow resolve these problems and rebind assembly link inside the application? With AppDomain.AssemblyResolve event or config-file?

Do Views get copied during a build of a DotNetNuke MVC Module based on the DNN project templates

I installed the DotNetNuke project templates for v 7,8,9 and added a new C# Compiled Module project. Whilst it seems that if I update the Controllers/Actions and compile then refresh the page I can see that the site is using the latest controller (because it's throwing an exception when I try to pass a different Model into the view).
But, compiling doesn't seem to update the views. The project template folders are placed directly in the DesktopModules/MyModule folder so I would have thought any changes made to a view would automatically be updated in the running site.
I've restarted IIS and it made no difference.
Howcome my views aren't updating?
Edit:
I just noticed now that during install DNN copies some of the MVC Module files to DesktopModules\MVC\MyModuleFolder. So the question now is: During development are you supposed to manually copy the view files from your project folder in the DesktopModules\MyModule\Views folder to the DesktopModules\MVC\MyModule\Views folder?
When using my MVC Template, you should use the path
/desktopmodules/mvc/ModuleName
instead of the path that gets used with all the OTHER templates.
/desktopmodules/ModuleName
Once you're using the right path, that should solve the "copy" problem, as nothing will need to be moved.

Report Definition Local Definition Error

i have a very strange problem.
i'm designing a winform app using C# and SQL. i have one reportviewer(its a local report) that is bound to a dataset that holds data of a select query.
the report viewer is working ok in both release and debug modes, i'm able to view data, able to export it without any hindrances..
So i went ahead and published my app using Install shield, along with all my other forms. and made the setup file
i installed the setup file on my PC for testing purpose. All forms are working fine except the report viewer. when i click on my generate report button, the error "An error Occurred during Local Report Processing, the report Defination for Report2.rdlc was not specified. Could not find.
C:\Users****\AppData\Local\Apps\2.0\C0AR0PT5.VRJ\DBE8ENNT.GWW\s.i...tion_61336ddcb5db67e9_0001.0005_09635aa1235e262b\Report2.rdlc "
What could be the reason, its working in VS2012 in both Debug as well as release mode.
Please help, What could be the issue?
You should embed the report as a project resource. As it seems, your application expects the report's RDLC file to be present outside the application as a file on the disk.
On your comment "How do I do that?":
Set "Build Type" for the RDLC file in Visual Studio to "Embedded Resource" and then read this. I'd like to add that you need to add the full namespace.
Example: your RDLC file is "MyReport.rdlc" and it's in the sub-folder "reports" of a project with default namespace "com.example.MyFirstProject". Then you need to set ReportEmbeddedResource to
com.example.MyFirstProject.resports.MyReport.rdlc

Categories

Resources