mirror of https://github.com/abpframework/abp.git
csharpabpc-sharpframeworkblazoraspnet-coredotnet-coreaspnetcorearchitecturesaasdomain-driven-designangularmulti-tenancy
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Tree:
129cd2dc00
10.0-ai-docs
2024-06-21-Use_User-Defined_Function_Mapping_For_Global_Filter
8.0-prevent-stackoverflow-blazor
9.0-clear-breadcrumbs
BackgroundJob-ApplicationName-Test
Blazorise-Form-Submit
EngincanV/10-6-release-posts
EngincanV/react-docs-updates
ExtensionPropertyPolicy-Test
IApplicationConfigurationContributor
IGuidGenerator
IReadOnlyAppService
InboxProcessor-OutboxSender
InteractiveServerRenderMode(prerender-true)
Issue-#23338
LockoutEnd-Time
NullAbpDistributedLock-patch
Operation-Rate-Limiting-Test
RandomHelper
Shared-User-Account
Testcontainers
Theme-Async
TimezoneHelpText
X509KeyStorageFlags
abp-plugin
abp-release-post
abp-studio/issue/2891
abp-united-pre-merge
add-loading-component
advanced-features
article/angular-multithreading
article/resource-based-api
auto-merge/prerel-8-2/2729
auto-merge/prerel-9-0/3134
auto-merge/prerel-9-0/3181
auto-merge/rel-0-0/42712
auto-merge/rel-0-0/42712-1
auto-merge/rel-10-0/4007
auto-merge/rel-10-0/4064
auto-merge/rel-10-0/4133
auto-merge/rel-10-1/4237
auto-merge/rel-10-2/4454
auto-merge/rel-10-2/4463
auto-merge/rel-10-4/4526
auto-merge/rel-10-5/4643
auto-merge/rel-10-5/4645
auto-merge/rel-10-5/4680
auto-merge/rel-10-5/4694
auto-merge/rel-7-4/2239
auto-merge/rel-7-4/2263
auto-merge/rel-7-4/2276
auto-merge/rel-8-0/2472
auto-merge/rel-8-0/2715
auto-merge/rel-8-0/2741
auto-merge/rel-8-1/2527
auto-merge/rel-8-2/2851
auto-merge/rel-8-3/3151
auto-merge/rel-9-0/3296
auto-merge/rel-9-0/3304
auto-merge/rel-9-1/3656
auto-merge/rel-9-2/3571
auto-merge/rel-9-2/3652
before-net10
blazor-full-stack-web-ui-interactiveauto
blazor-full-stack-web-ui-interactiveauto-modified
clear-breadcrumbs
cmskit-cache
codex/update-abp-ai-agent-deep-dive-title
copilot/allow-adding-public-website
copilot/sub-pr-24469
copilot/sub-pr-24636
copilot/sub-pr-24842
copilot/sub-pr-24889
copilot/sub-pr-24949
copilot/update-documentation-react-native
data-collection-code-review-2
data-collection-review-3
data-collection-review-5
dev
devnot-demo
dgnyldrm7-patch-1
docs-fix
docs-preview-8.3
docs-test-1
docs-unification
docs-unification-1-enhancements
docs/studio-2.2.1
docs/studio-2.2.2
docs/studio-2.2.3
docs/studio-2.2.4
document-abp-run-watch-command
document-index-backgroundjob
documentation/#20827-modular-monolith-application
documentation/20827
documentation/abp-extensible-form-doc
ebicoglu-patch-1
ebicoglu-patch-2
ebicoglu-patch-3
enisn-patch-1
enisn/blobstoring-bunnycdn
feat/#23955
feat/ai-assistant-article-enhancements
feat/dynamic-form-component
feat/mudblazor-mix
feat/typescript-on-mvc
feature/#19594
feature/#23180
feature/data-collection
feature/logo-provider
feature/ssr-migration-schematic
fix-admin-docs-test
fix/#20241
fix/#23795
fix/21899-resource-permission-refresh
fullstackblazor
gizem/HTML-encode-TagHelper-xss-test
gizem/security-logs
halil-presentation-2024-05
hybrid-ui
hybrid-ui-embedding
ingress-nginx/ingress-nginx
issue-#23231
issue-#3417
issue-#3591
issue-#3596
issue-#6679
issue-#6768
issue-18421
issue-19307
issue-20436
issue-20924-2
issue-21015
issue-22408
issue-23113
issue-23231
issue-23231-v2
issue-23286
issue-24272
issue-24438-test
issue-24635-test
issue-24672
issue-24674
issue-24918-2
issue-24918-bg-workers
issue-2884
issue-3384/L
issue-3596
issue-3870/L
issue-5131
issue-5384
issue-volo-21285
issue-vs-7809
issue/22675
issue/25581
issue/25678
issue/abp-ng-upgrade
issue/assign-available-port-for-suite
issue/ng-v22-upgrade-docs
issue/updateAngularInstallers
issut/7552
jenkins-abp-release-308
jquery-form-extensions.js-v2
leptonx-versions
license-banner-localization
license-banner-localization-1
local-ref-basic-theme
maliming-patch-1
maliming-patch-2
maliming-patch-4
maliming/ParameterApiDescriptionModel
maliming/ShouldValidatePredicates
maliming/fix-mauiblazor-bundling-net10
mansur-vs-internal-#7864
mauiglobalbundle
migrating-abp-packages/core
migrating-abp-packages/identity
migrating-abp-packages/setting-management
migrating-abp-packages/tenant-management
migrating-abp-packages/theme-shared
oauth2-redirect.html
patch-1-engincanv
pr/2526
pr/6814
prerel-9.0
rel-1.0
rel-1.1
rel-10.0
rel-10.1
rel-10.2
rel-10.3
rel-10.4
rel-10.5
rel-10.6
rel-2.0
rel-2.1
rel-2.2
rel-2.3
rel-2.4
rel-2.5
rel-2.6
rel-2.7
rel-2.8
rel-2.9
rel-3.0
rel-3.1
rel-3.2
rel-3.3
rel-4.0
rel-4.1
rel-4.2
rel-4.3
rel-4.4
rel-5.0
rel-5.1
rel-5.2
rel-5.3
rel-6.0
rel-7.0
rel-7.1
rel-7.2
rel-7.3
rel-7.4
rel-8.0
rel-8.1
rel-8.2
rel-8.3
rel-9.0
rel-9.1
rel-9.2
rel-9.3
remove-deprecateds
return-code-vs-exception-article
revert-18876-blazor-full-stack-web-ui
revert-20264-EngincanV/cli-old-vs-new
revert-23436-Mapperly-maliming
salihozkara-patch-1
salihozkara-patch-2
salihozkara/ImproveBundleFile
salihozkara/abp-low-code-community-article
salihozkara/blazorise-validation-message
salihozkara/complex-property
salihozkara/fix-image
salihozkara/fixDatePicker
salihozkara/low-code-docs-1
salihozkara/lowcode-page-interceptor-schemas
salihozkara/mapperly-test
scrapstation/dev
skoc10-patch-1
social-login-usages
studio-custom-command-doc
studio-document-start-and-wait
studio-linux-community-article
task/update-docs-for-the-samples
template-config-provider
templates-version
test-branch-24299
test-fix/resource-permission-definition-bugs
test/distribution-batch-state-checker-projection-on-10.4
update-bundle
update-cli-docs
update-doc
update-latest-versions-7.4.3
update-latest-versions-8.1.2
update-latest-versions-8.1.5
update-latest-versions-8.2.3
update-latest-versions-9.0.7
update-latest-versions-9.1.0
update-upgrade-cod-23-08-2024
upgrade-command-doc
vs-internal-issue-#7727
vsInternal-viewcChangeHistory-localization
vsinternal-7565
zh-hans.json
ìssue-17361
0.10.0
0.11.0
0.12.0
0.13.0
0.14.0
0.15.0
0.16.0
0.17.0.0
0.18.0
0.18.1
0.19.0
0.20.0
0.20.1
0.21.0
0.22.0
0.3.7
0.4.0
0.4.1
0.4.1.1
0.5.0
0.6.0
0.6.1
0.7.0
0.7.1
0.8.0
0.9.0
1.0.0
1.0.2
1.1.0
1.1.1
1.1.2
10.0.0
10.0.0-rc.1
10.0.0-rc.2
10.0.0-rc.3
10.0.1
10.0.2
10.0.3
10.1.0
10.1.0-rc.1
10.1.0-rc.2
10.1.0-rc.3
10.1.1
10.2.0
10.2.0-rc.1
10.2.0-rc.2
10.2.0-rc.3
10.2.0-rc.4
10.2.1
10.3.0
10.3.0-rc.1
10.3.0-rc.2
10.4.0
10.4.0-rc.1
10.4.0-rc.2
10.4.1
10.5.0
10.5.0-rc.1
10.5.0-rc.2
10.5.0-rc.3
10.5.0-rc.4
10.6.0-rc.1
2.0.0
2.0.1
2.1.0
2.1.1
2.2.0
2.2.1
2.3
2.3.0
2.4.0
2.4.1
2.5.0
2.6.0
2.6.1
2.6.2
2.7.0
2.8.0
2.9.0
3.0.0
3.0.1
3.0.2
3.0.3
3.0.4
3.0.5
3.1.0
3.1.0-rc.1
3.1.0-rc.2
3.1.0-rc.3
3.1.0-rc.4
3.1.1
3.1.2
3.2.0
3.2.0-rc.1
3.2.0-rc.2
3.2.1
3.3.0
3.3.0-rc.1
3.3.0-rc.2
3.3.1
3.3.2
4.0.0
4.0.0-rc.1
4.0.0-rc.2
4.0.0-rc.3
4.0.0-rc.4
4.0.0-rc.5
4.0.1
4.0.2
4.1.0
4.1.0-rc.1
4.1.0-rc.2
4.1.1
4.1.2
4.2.0
4.2.0-rc.1
4.2.0-rc.2
4.2.1
4.2.2
4.3.0
4.3.0-rc.1
4.3.0-rc.2
4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
9.0.2
9.0.3
9.0.4
9.0.5
9.0.6
9.0.7
9.0.8
9.1.0
9.1.0-rc.1
9.1.0-rc.2
9.1.0-rc.3
9.1.1
9.1.2
9.1.3
9.2.0
9.2.0-rc.1
9.2.0-rc.2
9.2.0-rc.3
9.2.0-rc.4
9.2.1
9.2.2
9.2.3
9.2.4
9.3.0
9.3.0-rc.1
9.3.0-rc.2
9.3.0-rc.3
9.3.0-rc.4
9.3.1
9.3.2
9.3.3
9.3.4
9.3.5
9.3.6
9.3.7
v0.3.1
v0.3.2
v0.3.2.1
v0.3.2.2
v0.3.3
v0.3.3.1
v0.3.3.2
v0.3.4
v0.3.5
v0.3.6
v0.6.2
v1.1.1
v9.2.0-preview
${ noResults }
3.0 KiB
3.0 KiB
使用Console Application
本教程将介绍如何从头开始以最小的依赖关系启动ABP. 你通常希望以 启动模板 开头.
创建一个新项目
使用Visual Studio创建一个新的.Net Core Console应用程序:
安装 Volo.Abp 包
Volo.Abp.Core是创建基于ABP的应用程序的核心nuget包. 所以,将它安装到你的项目中:
Install-Package Volo.Abp.Core
创建第一个ABP模块
ABP是一个模块化框架, 它需要一个从AbpModule类派生的 启动(根)模块 类:
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity;
namespace AbpConsoleDemo
{
public class AppModule : AbpModule
{
}
}
AppModule 是应用程序启动模块的好名称.
初始化应用程序
下一步是使用上面创建的启动模块引导应用程序:
using System;
using Volo.Abp;
namespace AbpConsoleDemo
{
class Program
{
static void Main(string[] args)
{
using (var application = AbpApplicationFactory.Create<AppModule>())
{
application.Initialize();
Console.WriteLine("Press ENTER to stop application...");
Console.ReadLine();
}
}
}
}
AbpApplicationFactory 用于创建应用程序并加载所有以AppModule作为启动模块的模块. Initialize()方法启动应用程序.
Hello World!
上面的应用程序什么都不做, 让我们创建一个服务做一些事情:
using System;
using Volo.Abp.DependencyInjection;
namespace AbpConsoleDemo
{
public class HelloWorldService : ITransientDependency
{
public void SayHello()
{
Console.WriteLine("Hello World!");
}
}
}
ITransientDependency是ABP的一个特殊接口, 它自动将服务注册为Transient(参见依赖注入文档).
现在,我们可以解析HelloWorldService并调用SayHello. 更改Program.cs, 如下所示:
using System;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp;
namespace AbpConsoleDemo
{
class Program
{
static void Main(string[] args)
{
using (var application = AbpApplicationFactory.Create<AppModule>())
{
application.Initialize();
// 解析服务并使用它
var helloWorldService =
application.ServiceProvider.GetService<HelloWorldService>();
helloWorldService.SayHello();
Console.WriteLine("Press ENTER to stop application...");
Console.ReadLine();
}
}
}
}
这对于这个简单的代码示例已足够, 如果是直接从IServiceProvider解析建议创建Scoped依赖.(参见依赖注入文档).
源码
从这里获取本教程中创建的示例项目的源代码.
