question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

MacroService.GetAll(Guid[]) throws an error

See original GitHub issue

PR https://github.com/umbraco/Umbraco-CMS/pull/5962

When I attempt to use the MacroService to get a selection of Macro’s by Guid, an error is thrown.

Reproduction

Bug summary

When calling MacroService.GetAll method, passing in an array of Guids, the following exception is thrown…

Exception Details: System.InvalidOperationException: Cannot run a repository without an ambient scope.

Specifics

Umbraco version: v8.1.0

Stack Trace snippet:

[InvalidOperationException: Cannot run a repository without an ambient scope.]
   Umbraco.Core.Persistence.Repositories.Implement.RepositoryBase`2.get_AmbientScope() in d:\a\1\s\src\Umbraco.Core\Persistence\Repositories\Implement\RepositoryBaseOfTIdTEntity.cs:43
   Umbraco.Core.Persistence.Repositories.Implement.MacroRepository.GetBaseQuery() in d:\a\1\s\src\Umbraco.Core\Persistence\Repositories\Implement\MacroRepository.cs:109
   Umbraco.Core.Persistence.Repositories.Implement.MacroRepository.Get(Guid id) in d:\a\1\s\src\Umbraco.Core\Persistence\Repositories\Implement\MacroRepository.cs:31

Steps to reproduce

  • Create a Macro in the back-office, make note of the GUID
  • Then, wherever you want to try the C#, controller or Razor view, whichever, try this code…
var guid = new Guid("INSERT-MACRO-GUID-HERE");
var macros = Services.MacroService.GetAll(guid);
foreach (var macro in macros)
{
    // do stuff
}
  • As soon as the enumerable is evaluated, the exception will be thrown.

Expected result

  • I expected a list of Macro objects (by given GUID) to be returned.

Actual result

  • The exception, see above.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
kjaccommented, Jul 19, 2019

@leekelleher I figured as much. Just thought you should know all the same 😄

1reaction
leekellehercommented, Jul 19, 2019

Thanks @kjac, I appreciate it! I’ve been meaning to take a look at patching it myself, but it’s already been on my to-do list for 2 months, doh! Thought it best to raise the bug report.

I’m using GUIDs because it’s one less Deploy thing to worry about. (And we’re meant to be “GUID ALL THINGS!” now, right? 😉)

Thanks again for the patch! #h5yr

Read more comments on GitHub >

github_iconTop Results From Across the Web

unable to render form in richtext editor 30180 umbraco 7 - Contour
2014-01-22 13:38:22,309 [6] WARN umbraco.macro - [Thread 21] Error loading ... but when i add macro to RTE not in Template then its...
Read more >
Microservices with ASP.NET Core 3.1 - Ultimate Detailed ...
Create Service with CRUD operations. Create ASP.NET Core Project ; Add Web API versioning. Implement Web API versioning using URL ; Add logging...
Read more >
Microservice SDK for Java - Cumulocity IoT Guides
In case of errors, such as invalid names, you will get the details ... Review also the Java example in this guide to...
Read more >
EntityController.cs
Document); throw new ArgumentException("Get by query is only compatible with ... Macro: //Get all macros from the macro service; var macros = Services....
Read more >
Why I believe Rails is still relevant in 2019
"more error prone and less safe". right there... if I could vote you up a thousand times, I would. I can place a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found